Line 2 of code is the only one that works - acrobat

Line 4 of this code won't work but there is no error code. It's a building permit application form. If the applicant chooses any category but New Residential from ConstructionType dropdown the minimum fee is 60 for a deck under 401 sq. ft. & .15 x value of Deck text field for a deck >=401. These work. If New Residential is chosen the fee is strictly .15 x value of Deck field. This is the part that doesn't work. Here is the code.
var nDeck = this.getField("Deck").value;
if( (nDeck >0 ) && ( nDeck <= 400) ) event.value = 60 ;
else if(nDeck >= 401 ) event.value = nDeck *0.15 ;
else if ( ConstructionType = "New Residential" ) event.value = nDeck *0.15;
else event.value = 0 ;

Mmmh, at least
ConstructionType = "New Residential"
must be
ConstructionType == "New Residential"
HTH, Reinhard

Related

Unable to set date values in SAP B1 matrix combobox

I am trying to set values in a matrix combobox but I cannot be able to set the first value of date to that combobox. It shows blank and when I select a date, it does not fill the field anyway.
The values I get from the DB are as follows:
Here is my code below including binding the combobox field to a userdatasource:
_expDate = _form.DataSources.UserDataSources.Add("iV_15", SAPbouiCOM.BoDataType.dt_DATE, 100);
oIColumns = oIMatrix.Columns;
_colExpDate = oIColumns.Item("iV_15");
_colExpDate.DataBind.SetBound(true, "", "iV_15");
The below code runs when there is a lost focus change event to the item selection field:
#region Item Change Event Expiry dates
_cmbExpDate = (SAPbouiCOM.ComboBox)oIMatrix.Columns.Item("iV_15").Cells.Item(pVal.Row).Specific;
int count = _cmbExpDate.ValidValues.Count;
if (count > 0)
{
_expDate.ValueEx = "";
for (int j = 0; j <= count - 1; j++)
_cmbExpDate.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index);
}
var expDates = (from oi in _db.OITMs
join ob in _db.OBTNs
on oi.ItemCode equals ob.ItemCode
where ob.ItemCode == _itemNo.ValueEx && oi.OnHand > 0
orderby ob.ExpDate
select new
{
ExpDate = ob.ExpDate
}).Distinct().ToList();
if (expDates.Count > 0)
{
foreach (var item in expDates)
_cmbExpDate.ValidValues.Add(item.ExpDate?.ToString(), item.ExpDate?.ToString());
_cmbExpDate.Select(0, SAPbouiCOM.BoSearchKey.psk_Index);
_expDate.ValueEx = _cmbExpDate.Value;
}
#endregion
What could be wrong. Is there a better way to achieve what I need in SAP B1?
as a test try a different data type for your:
_expDate = _form.DataSources.UserDataSources.Add("iV_15", SAPbouiCOM.BoDataType.dt_DATE, 100);
test it with: SAPbouiCOM.BoDataType.dt_LONG_TEXT
you can also try just selecting the value on the combo, instead of setting uds as well.

Passing a variable into SQL string

I'm modifying someone else's showershell script that's used within our database to try and have it do some extra steps behind the scenes: reject code, location code, and start date.
It starts by asking for 3 values to pass as variables, but I want to add 2 additional values using a dictionary based on the location code. I don't want to share the entire batch - I know it works without this one specific part, but I'll include enough to illustrate my point.
The issue is with the variables $AREA1 and $AREA2 - these are what I'm trying to add.
The "parameters" are being injected using one way where it asks for the user to supply them but i don't want the user to supply these, they're supposed to be a lookup.
For instance, if the LOC was 5300 then AREA1 should be 101 and AREA 2 should be 111.
param(
[ImdsParameter(FullName = "REJ_CODE", Description = "Enter a 4 digit reject code to filter the data. Will not run without one.", Length = 4)]
[string] $REJ,
[ImdsParameter(FullName = "LOC", Description = "The Location code you want to run this against. Example 5300.", Length = 4)]
[string] $LOC,
[ImdsParameter(FullName = "STDTE", Description = "Start date. This is the start date from how back to run the report. Example 2021-01-01", Length = 10)]
[string] $STDTE
)
$areaStart = #{
5300 = 101 ;
5304 = 112 ;
5305 = 123 ;
5306 = 134 ;
//there’s well over 100 of these
}
$areaEnd = #{
5300 = 111 ;
5304 = 122 ;
5305 = 133 ;
5306 = 144 ;
//same
}
$AREA1 = $areaStart.Get_Item($LOC)
$AREA2 = $areaEnd.Get_Item($LOC)
$jobSql = #"
SELECT TB1.dataitem1,
TB1. Dataitem2,
TB1. Dataitem3,
TB2. Dataitem1
FROM firstTable AS TB1 INNER JOIN secondTable AS TB2
ON TB1. dataitem = TB2. dataitem
WHERE TB1.LOCATION = #LOC AND TB2.AREA BETWEEN '$($AREA1)' AND '$($AREA2)'
"#
$edbms = Get-Rdms -SQL $jobSql -Parameters #{LOC = $LOC; REJ = $REJ; STDTE = $STDTE; }
$edbms | ConvertTo-Csv -NoTypeInformation
EDIT: I need to add that the script will run, but returns no data. If I just plug the SQL in with all the values manually, it will run just fine.
Thank you for your time.
The values in the SQL were being treated as strings while the values in the dictionaries were being treated as numbers.
I changed this:
5300 = 101 ;
5304 = 112 ;
5305 = 123 ;
5306 = 134 ;
To this:
'5300' = '101' ;
'5304' = '112' ;
'5305' = '123' ;
'5306' = '134' ;
And it provided the data expected.

Looping to a certain number based on some condition for a soap request

Scenario : send post request until a condition meet but maximum 5 times otherwise fail the script
step1: get one data from database
step2: get 2nd data from db based on step one result(if step 2 gives null then start again from step 1 and maximum occurrence can be 5 times)
step3: prepare a soap request and put 1st and 2nd data as input in the request body which we got in step 1 and 2.
Step4: send a soap request and print the response
step5: validate if response.id >5000(if this condition doesn't fulfill repeat the process from step1 to step 5 but again repeat only till 5 times and if still condition doesn't fulfill till 5th time then fail the test case)
Note:- I tried with retry until as well but looks like it keeps sending the step 5 only so it will not change the request body data which we need to change after every run from step 1 to step 5.
Also, I researched a lot and came across many similar questions but couldn't achieve my desired result.
Condition based on response value in karate
Scenario: GetCountriesWithId
* def RandomNumber =
"""
function() {
var count = 1
while (count<=5) {
var RandomNumber = db.readRows("select trunc(dbms_random.value(10000000, 10010000)) min, trunc(dbms_random.value(10200000, 10250000)) max from dual")
karate.log('RandomNumber->',RandomNumber)
var HolderFromDB = db.readRows("SELECT productId, userId from table1 WHERE id between "+RandomNumber[0].MIN+" and "+RandomNumber[0].MAX+" ")
if (HolderFromDB.length >= 1) {
karate.log('condition satisfied, exiting');
return HolderFromDB;
}
count++
}
}
"""
* def HolderFromDB = call RandomNumber
* def productId = HolderFromDB.productId
* def userId = HolderFromDB.userId
* def javaclass = Java.type('epos.positionmanagement.service.test.GetSpendingLimitRequestTest')
* def map = {deviceTypeId: 2, entityId: '#(defaultEntity)', ppr_id: '#(productId)', userId: '#(userId)' }
* def createGetSpendingLimitRequest = javaclass.getPayload(map)
Then print 'Request body--->', createGetSpendingLimitRequest
Given request createGetSpendingLimitRequest
When soap action 'Request'
Then status 500
Then print '\n', response
* def revisionId = get response //GetSpendingLimitResponse/spendingLimit/totalAmount*1
* def result = revisionId<=50000 ? karate.call('test1.feature') : {}
I think this test case should not be automated. Because it is not clear and it has a lot of dependent situation. You should take principle for making each test case standalone and independent. Also Test cases should have been good designed so that you can easily develop a code for them. Otherwise even if you have achieved to automate them, they will be most probably flaky tests and you will spend more time to fix them instead of testing them manually. Think twice, think scenarios once more also and decide your next move. Also please take a look this business logic which mentioned in your scenarios once more since it doesn't look so logical.
I have resolved the issue as below:-
Put the steps till post request in another feature file as below:-
#ignore
Feature: Reusable
Background: Maintenance Soap Request
* def DbUtils = Java.type('util.DbUtils')
* def db = new DbUtils(eposEnvironment.database[defaultEntity])
* url eposEnvironment.baseUrl
#Limit-GTC-Straddle #parallel=false
Scenario: Limit-GTC-Straddle
* def derivativeOrderTemp =
"""
function() {
var count = 1
while (count <= 10) {
var selectRandomLetter = db.readRows("select chr(trunc(dbms_random.value(65,74))) firstLetter, chr(trunc(dbms_random.value(80,90))) lastLetter, trunc(dbms_random.value(1, 4)) positionToBuy, to_char(current_date + 364, 'YYYY-MM-DD') expDate from dual")
var symbol1FromDB = db.readRows("select * from (select be_symbool, RTRIM(be_muntsoort) as be_muntsoort, be_code, be_optietype, be_expiratiedatum as be_expiratiedatum2, to_char(to_date(be_expiratiedatum, 'YYYYMMDD'), 'YYYY-MM-DD') as be_expiratiedatum, be_exerciseprijs, brs_naam, be_bv_beurs, round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0) as limit, (round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0)*100*-1*" + selectRandomLetter[0].POSITIONTOBUY + ") effAmount, be_volgnummer from beleggingsinstrument join fn_quotes_table on quot_symbool = be_symbool and quot_optietype = be_optietype and quot_expiratiedatum = be_expiratiedatum and quot_exerciseprijs = be_exerciseprijs join beurzen on brs_nummer = be_bv_beurs where be_Symbool in (select be_symbool from beleggingsinstrument where be_bi_nummer = 100 and length(trim(be_symbool)) < 4 and substr(trim(be_symbool),1,1) between '" + selectRandomLetter[0].FIRSTLETTER + "' and '" + selectRandomLetter[0].LASTLETTER + "' and be_geblokkeerd = 0 and be_handelen_toegestaan = 1 and be_referentiesymbool = ' ') and be_optietype = 'CALL' and be_handelen_toegestaan = 1 and be_expiratiedatum > to_char(sysdate, 'yyyymmdd') group by be_symbool, be_muntsoort, be_code, be_optietype, be_expiratiedatum, be_exerciseprijs, be_bv_beurs, quot_laat, brs_naam, quot_laat, quot_datum, be_volgnummer ) where rownum = 1")
karate.log('Symbol1FromDB-->', symbol1FromDB)
if (symbol1FromDB.length >= 1) {
karate.log('condition satisfied, exiting from first conditionalGoto1 loop counter');
var indirectCosts1FromDB = db.readRows("select icf_cfcu_id, cfcu_description, decode(icf_amount, null, 0, icf_amount) icf_amount, decode(icf_currency, null, 'NULL', icf_currency) icf_currency, decode(icf_percentage, null, 0, icf_percentage) icf_percentage from EPP_OWNER.INDIRECT_COSTS_PER_FUND join epp_owner.calculationrules on cfcu_id = icf_cfcu_id where icf_be_id = " + symbol1FromDB[0].BE_VOLGNUMMER + " and (icf_import_date_till > to_char(sysdate, 'yy-mm-dd') or icf_search_date_till is null) and icf_ex_ante_ex_post_ind = 'A' and icf_cfcu_id in (67)")
karate.log('indirectCosts1FromDB-->', indirectCosts1FromDB)
var symbol2FromDB = db.readRows("select * from (select be_symbool, RTRIM(be_muntsoort) as be_muntsoort, be_code, be_optietype, to_char(to_date(be_expiratiedatum, 'YYYYMMDD'), 'YYYY-MM-DD') as be_expiratiedatum, be_exerciseprijs, brs_naam, be_bv_beurs, round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0) as limit, (round(max (quot_laat) keep (dense_rank last order by quot_datum)+ 1, 0)*100*-1*" + selectRandomLetter[0].POSITIONTOBUY + ") effAmount, be_volgnummer from beleggingsinstrument join fn_quotes_table on quot_symbool = be_symbool and quot_optietype = be_optietype and quot_expiratiedatum = be_expiratiedatum and quot_exerciseprijs = be_exerciseprijs join beurzen on brs_nummer = be_bv_beurs where be_Symbool = '" + symbol1FromDB[0].BE_SYMBOOL + "' and be_optietype = 'PUT' and be_handelen_toegestaan = 1 and be_expiratiedatum = '" + symbol1FromDB[0].BE_EXPIRATIEDATUM2 + "' group by be_symbool, be_muntsoort, be_code, be_optietype, be_expiratiedatum, be_exerciseprijs, be_bv_beurs, quot_laat, brs_naam, quot_laat, quot_datum, be_volgnummer ) where rownum = 1")
karate.log('Symbol2FromDB-->', symbol2FromDB)
var indirectCosts2FromDB = db.readRows("select icf_cfcu_id, cfcu_description, decode(icf_amount, null, 0, icf_amount) icf_amount, decode(icf_currency, null, 'NULL', icf_currency) icf_currency, decode(icf_percentage, null, 0, icf_percentage) icf_percentage from EPP_OWNER.INDIRECT_COSTS_PER_FUND join epp_owner.calculationrules on cfcu_id = icf_cfcu_id where icf_be_id = " + symbol2FromDB[0].BE_VOLGNUMMER + " and (icf_import_date_till > to_char(sysdate, 'yy-mm-dd') or icf_search_date_till is null) and icf_ex_ante_ex_post_ind = 'A' and icf_cfcu_id in (67)")
karate.log('indirectCosts2FromDB-->', indirectCosts2FromDB)
var selectRandomNumber = db.readRows("select trunc(dbms_random.value(10020000, 10050000)) min, trunc(dbms_random.value(11000000, 11500000)) max from dual")
karate.log('selectRandomNumber-->', selectRandomNumber)
var holderFromDB = db.readRows("SELECT * from (select ap_relatienr, ap_rekeningnr, hpp_holdernummer, ppr_id from aktuele_posities ap join epp_owner.rekeningen_per_product on rpp_relatienummer = ap.ap_relatienr and rpp_rekening_nummer = ap.ap_rekeningnr and rpp_rekeningsoort = ap.ap_rekening_soort join epp_owner.holders_per_product on hpp_relatienummer = rpp_relatienummer and hpp_product = rpp_productnummer and hpp_product_volgnr = rpp_volgnr_per_product and hpp_type_holder = 1 join rekeningen on re_rekening = rpp_rekening_nummer and re_nummer = rpp_relatienummer and re_rekening_status = 2 join epp_owner.wwwusers on wus_holder = hpp_holdernummer and wus_userblocked = 0 join producten_per_relatie on ppr_relatienummer = rpp_relatienummer and ppr_productnummer = rpp_productnummer and ppr_volgnr_per_product = rpp_volgnr_per_product JOIN on_line_dossier onld ON onld.onld_relatienummer = hpp_relatienummer and onld_productnummer = rpp_productnummer join kennis_per_client a on rpp_relatienummer = ke_clientnr where rpp_productnummer = 100 and rpp_volgnr_per_product = 1 and ap.ap_rekening_soort = 1000 and ap_saldo_positie > 7000 AND ap.ap_relatienr between " + selectRandomNumber[0].MIN + " and " + selectRandomNumber[0].MAX + " and onld.onld_klasse = 16 and onld.onld_ontvangstdatum <> '00000000' and onld.onld_vervaldatum = '00000000' and ((ke_kennis_niv = 'V' or ke_ervaring = 'V') and ke_mifcat_id = 25) and not exists (select 1 from kennis_per_client b where (ke_kennis_niv = 'O' or ke_ervaring = 'O') and a.ke_clientnr = b.ke_clientnr) and rpp_relatienummer in (select cl_nummer from clienten where cl_nummer between " + selectRandomNumber[0].MIN + " and " + selectRandomNumber[0].MAX + " and cl_geb_datum < to_char(add_months(sysdate, -216), 'YYYYMMDD')) and not exists (select 1 from profiel_toevoeging_verwijderen where ptv_relatie = ap.ap_relatienr) and not exists (select 1 from rekeninghouders_details where UPPER(eor_compliancecode) like 'INSIDER%' and eor_partij_id = hpp_holdernummer) ) where rownum = 1")
karate.log('holderFromDB-->', holderFromDB)
while (count <= 10) {
if (holderFromDB.length >= 1) {
karate.log('condition satisfied, exiting from conditionalGoto2');
productId = holderFromDB[0].get('PPR_ID')
userId = holderFromDB[0].get('HPP_HOLDERNUMMER')
return {
productId,
userId
};
}
count++;
if (count >= 9) {
karate.fail('Count exceeded more than 10 times and conditionalgoto2 loop counter failed')
}
}
count++;
if (count >= 9) {
karate.fail('Count exceeded more than 10 times and conditionalgoto1 loop counter failed')
}
}
}
}
"""
* def derivativeTemp = call derivativeOrderTemp
* def productId = derivativeTemp.productId
* print 'Product Id is-->',productId
* def userId = derivativeTemp.userId
* print 'User Id is-->',userId
################GetSpendingLimit###########################
* def javaclass = Java.type('epos.positionmanagement.service.test.GetSpendingLimitRequestTest')
* def map = {deviceTypeId: 2, entityId: '#(defaultEntity)', ppr_id: '#(productId)', userId: '#(userId)' }
* def createGetSpendingLimitRequest = javaclass.getPayload(map)
Then print 'Request body--->', createGetSpendingLimitRequest
Given request createGetSpendingLimitRequest
When soap action 'Request'
Then print '\n', response
And then call this feature file from other test case feature file as below :-
#Ordering
Feature: CreateCombinationDerivativeOrderTemp
Background: Ordering Soap Request
* url eposEnvironment.baseUrl
#parallel=true
Scenario: Limit-GTC-Straddle
* call read('reusable.feature#Limit-GTC-Straddle')
* def revisionId = get response //GetSpendingLimitResponse/spendingLimit/totalAmount*1
# * eval for(var i=0; i<=10; i++) (revisionId<3000 && i<10 ? karate.call('request1.feature') : karate.fail('Condition did not fulfill in 10 occurrence hence failing the test case'))
* def condionalgoto3 =
"""
function() {
for (var i = 0; i <= 10; i++) {
if (revisionId < 3000) {
karate.call('request1.feature')
if (i >= 9) {
karate.fail('Count exceeded more than 10 times and conditionalgoto3 loop counter failed')
}
}
}
}
"""
* call condionalgoto3
Note :- These java classes I am using to create a payload xml which was requirement of the project and these java classes are nothing but the actual services which I have added as pom dependency in my project which directly gives me the payload xml request and I just create a map and fill the value in the request body so these java classes are mandatory to use.And also these db queries are being used to fetch the actual customer details from a database to prepare the request body so there is nothing which I can ignore or improve in this test case but yes in some queries they are using some random values to fetch some customer data that I can definitely use some Java/Js/Karate.range() but apart from that I really dont think I can improve anything here.

How to get a variable name that is created in a for loop

Basically I have a for loop that is creating variables based on data in a database, I then have an event listener that is also created based on the for loop and I want to know which text is pressed
Ive tried events in the function, creating a variable for my row.name etc.
for row in db:nrows( "SELECT * FROM Students WHERE Class = '"..class.."'" ) do
print(row.Name)
--track how many students there are
count = count+1
--When displaying the names, put them in line, if they go below 1000 y level, move to the right and go down again
ny = ny + 80
if (ny == 1000) then
nx = nx + 300
ny = 280
end
-- Display students
student[row] = display.newText( sceneGroup, row.Name, nx, ny, native.systemFont, 30 )
--Make a button for every student in the row that goes to studentscene function
student[row]:addEventListener( "tap", studentscene)
end
The function then looks like
local function studentscene()
composer.gotoScene( "student", { time=800, effect="crossFade" } )
end
I want to be able to track which student name was pressed, yet i cannot find a way to do so. I need this so I can track in the database which name it is so I can display their information
you can add it by using params in goto function
`options = {
effect = model,
time = time,
params = params,
}
composer.gotoScene( nextScene , options )`
for example do this params = {student="mohsen"}
and in scene:show function do this :
if event.params then
studen = event.params.name
end

PL/SQL - Aggregate values & Write to table

I am just starting to dabble in PL/SQL so this question may be very straightforward. Here is the scenario:
I have several checkboxes which carry a weighted numeric value. For example:
Checkbox I --> Value '5'
Checkbox II --> Value '10'
Checkbox III --> Value '15'
etc.
The form would have 15 checkboxes in total and the end-user can select anywhere from 0 to all 15. As they select the checkboxes, the total weight would get calculated and a final numeric value would be displayed. For example. checking off 3 Checkbox I & 2 Checkbox III would = 45 points.
Now the total value of 45 would equal to a separate value. Example:
At 0 points, value = 'Okay'
1-15 points, value = 'Error'
16-30 points, value = 'Warning'
31+ points, value = 'Critical'
The form itself is built within Oracle APEX and I can do it using Dynamic Actions but using PL/SQL may be a better solution.
In summary, I'd like the hidden field to first calculate the total from the checked checkboxes and then use that total to figure out the value of either Okay, Error, Warning, or Critical.
Any assistance is much appreciated!
In my experience, it is better if we're going to use javascript on your case since we have to manipulate DOM and events of the checkboxes. If you want to display/change item values and get values at runtime, then javascript is better in doing that than PLSQL unless you want to submit your page every time you check/uncheck a box in your page which is not advisable.
Here is my solution for your question.
First, create a Display Only item on your page. This is where the values "Okay", "Error", "Warning", or "Critical" will appear. And its very important to set it's default value to 0. Then inside your page's "Function and Global Declaration" part, put the following functions:
function getcheck(checkbox_id,displayOnly_id){
var chkboxName = document.getElementById(checkbox_id + "_0").getAttribute("name");
var chks = document.getElementsByName(chkboxName);
var howmanychecks = chks.length;
var currentSum=0;
var v_remarks = "";
for(x=0;x<howmanychecks;x++){
chks[x].setAttribute("onchange","checkIfchecked(this,\'" + displayOnly_id + "\')");
if(chks[x].checked){
currentSum = currentSum + Number(chks[x].value);
}
}
if(currentSum==0){
v_remarks = "Okay";
}
else if(currentSum>0 && currentSum<=15){
v_remarks = "Error";
}
else if(currentSum>15 && currentSum<=30){
v_remarks = "Warning";
}
else{
v_remarks = "Critical";
}
document.getElementById(displayOnly_id).value = currentSum;
document.getElementById(displayOnly_id + "_DISPLAY").innerHTML = currentSum + ": " + v_remarks;
}
function checkIfchecked(p_element, displayOnly_id){
var v_difference;
var v_sum = Number($v(displayOnly_id));
var displayOnly_display = displayOnly_id + "_DISPLAY";
var v_remarks = "";
if(p_element.checked){
v_sum = v_sum + Number(p_element.value);
$("#" + displayOnly_id).val(v_sum);
}
else{
v_difference=Number($("#" + displayOnly_id).val())-Number(p_element.value);
if(v_difference<0){
v_difference=0;
}
$("#" + displayOnly_id).val(v_difference);
}
if($("#" + displayOnly_id).val()==0){
v_remarks = "Okay";
}
else if($("#" + displayOnly_id).val()>0 && $("#" + displayOnly_id).val()<=15){
v_remarks = "Error";
}
else if($("#" + displayOnly_id).val()>15 && $("#" + displayOnly_id).val()<=30){
v_remarks = "Warning";
}
else{
v_remarks = "Critical";
}
document.getElementById(displayOnly_display).innerHTML=$("#" + displayOnly_id).val() + ": " + v_remarks;
}
The above functions will get the sum of the values of those boxes that are checked. A value of a box will be taken out of the current sum if it is unchecked as well. It will also display the remarks for the current checked points whether if it is "Okay", "Error", "Warning", or "Critical".
In your "Execute when Page Loads" part of your page, add the following line:
getcheck(nameofyourcheckboxitem,nameofyourdisplayonlyitem);
where nameofyourcheckboxitem is the name of your Check Box and nameofyourdisplayonlyitem is the name of the Display Only item you have just created.
Here's a sample line on how to use the function that I've given you:
getcheck("P1_MYCHECKBOX","P1_MYDISPLAYONLY");