Multipe If conditions not working in JMeter IF controller - jmeter

I need to execute specific api only for dedicated users from CsvTestconfig file
Test1
Test2
Test3
Test4
...
Test40
For example:
API1 to be executed only by users (Test1, Test2, Test3, Test4)
I have used below code in JMeter IF condition.
but it is not working as expected. for single condition it works fine.
${__javaScript("${LOGINUSER}" == "Test1" || "${LOGINUSER}" == "Test2" || "${LOGINUSER}" == "Test3" || "${LOGINUSER}" == "Test4")}
API2 should be executed by all other users except users (Test20, Test22, Test30)
${__javaScript("${LOGINUSER}" != "Test20" || "${LOGINUSER}" != "Test22" || "${LOGINUSER}" != "Test30")}
Appreciate if anyone can help on this.
Thanks

please use __jexl3 or __groovy as suggested and vars.get is recommended to fetch variables

Related

Basic Scripting help needed for terraform

I have this local in terraform:
aws-temporary = var.environment == "dev" ? "aws." : ""
now this is called in line:
name = "${var.hostname}.${local.aws-temporary}${data.aws_route53_zone.management_zone.name}"
Now when the "var.environment" is dev .. it does add the ".aws" in the name. However, when it is something else than dev .. it does not add the ".aws".
What I want is that it adds the .aws in dev and other envs.. but not add in dev2.
How would I modify the local to do that? any help would be appreciated. thank you
I would just switch the condition to:
aws-temporary = var.environment == "dev2" ? "" : "aws."
Or another variation of the same:
aws-temporary = var.environment != "dev2" ? "aws." : ""

How to include session id in APEX_UTIL.PREPARE_URL?

I'm running Apex 20.1 and I need to generate some urls that includes the checksum and the session (that's mandatory)
I'm doing :
Output := APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || ApplicationAlias || ':' || PageAlias || ':' || SessionId ||'::::' || Arguments || ':' || ArgumentsValues, p_checksum_type => 'SESSION');
with :
-- for example
Arguments := 'param1,param2';
ArgumentsValue := 'value1,value2';
This command works properly but the URL is missing the session.
The URL Returned is :
https://www.example.com/ords/schema/r/myapp/pagealias?
param1=value1&
param2=value2&
cs=3BSsM-dn0SHfT0DBLYTRIHlSC_71paQVC0VQ_Hfa6YuVc-DzsnTzEs6yH
Now I need to have the session included in the URL. Means at the end of the URL I should have
&session=45654654987
I tried adding the session manually like :
Output := Output || '&session=' || v('APP_SESSION');
This works only for standard pages and not modal pages. So for modal pages I'm doing like :
-- Output generated from APEX_UTIL.PREPARE_URL :
javascript:apex.navigation.dialog(
'\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
param1=value1\u0026
param2=value2\u0026
cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ',
{title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));
Trick to fix it :
Output := replace(Output, ',{title' , '&session=' || v('APP_SESSION') || ',{title');
That returns
javascript:apex.navigation.dialog(
'\u002Fords\u002Fschema\u002Fr\u002Fmyapp\u002pagealias?
param1=value1\u0026
param2=value2\u0026
cs=3_XtJdikM6ypsgs1BPNLnh3dKfHI5-gbFl0YMA78wn032WRoN8Z4PoFDOmQJ9RvaMkW1q-Uk-x9BNEaunXyY_hw\u0026
dialogCs=fC8UqaERKj1k7OONTBxSKhPe4GeVKJ4Mk0nSTNDMRIR0o5hpagnDAKoNiYHzqcWo5Q6FgikwEvkbfQBdNE7MtQ&
session=98798798797',
{title:'Page title',height:'auto',width:'720',maxWidth:'960',modal:true,dialog:null},'t-Dialog-page--standard '+'',apex.jQuery('#regionId'));
Is there any better way to do this please ?
Thanks.
Cheers,
Instead of using APEX_UTL.PREPARE_URL, have you tried using APEX_PAGE.GET_URL? In the APEX 21.2 documentation for APEX_UTIL.PREPARE_URL, it is recommended to use APEX_PAGE.GET_URL instead of APEX_UTIL.PREPARE_URL.
APEX_PAGE.GET_URL has a parameter to include the APEX session id so it should properly build the session id into the URL depending the type of page you are navigating to. The checksum will also automatically be generated in the URL as long as you are navigating within the same workspace as your current session.
APEX_PAGE.GET_URL will also return the URL in "friendly" syntax if "friendly URLs" are enabled for the application of the page you are navigating to.

Validation while posting Journal Transactions AX 2009

I wanted to make a field (salesTax) mandatory in Ledgerjournaltrans Table through code only for specific Company.
I have written the code in LedgerjournalCheckPost Class--> Checkjournal method(). Validation should be done while checking and posting the journal transactions.
The written code is never invoked. Can you please tell me what is going wrong. Thanks in Advance.
if(ledgerJournaltrans.AccountNum > '29999' || ledgerJournaltrans.OffsetAccount > '29999' && !ledgerJournaltrans.TaxGroup && ledgerJournaltrans.dataAreaId == 'EUR')
{
allok = checkfailed('Tax Group is Mandatory');
}

How to run REST-call simultanously or with a lower priority

I am loading data via a REST call and rendering it. After that, I am calling another REST API which takes about 10 seconds. In this time, I can't make another REST call until this one is finished. My question is, how can I do this?
I tried with a thread, but it is not working, maybe I am doing something wrong, or maybe threads are not the correct choice?
This is the called route:
get '/api/dashboard/:dbnum/block/:blnum/inbackground/:inbackground' do
user = get_current_userobject
return assemble_error('LOGIN', 'NOTLOGGEDIN', {}, []).rest_fail if !user
dbnum,blnum = params[:dbnum].to_i, params[:blnum].to_i
return { rows: [] }.rest_success if !user.dashboardinfo || !user.dashboardinfo[dbnum] || !user.dashboardinfo[dbnum]['blocks'] || !(block = user.dashboardinfo[dbnum]['blocks'][blnum]) || !respond_to?("dashboard_type_#{block['type']}", true)
if params[:inbackground] == 'true'
t = Thread.new do
t.priority= -1
ret = method("dashboard_type_#{block['type']}").call(block['filters'], false, true)
ret.rest_success
end
t.join
t.exit
else
ret = method("dashboard_type_#{block['type']}").call(block['filters'], false, false)
ret.rest_success
end
end
How can I run the code inside line 8 to 22 in the 'background' so other calls have, like, priority?
The command t.join waits for a thread to finish. If you want your thread to run in the background, just fire and forget:
get '/api/dashboard/:dbnum/block/:blnum/inbackground/:inbackground' do
user = get_current_userobject
return assemble_error('LOGIN', 'NOTLOGGEDIN', {}, []).rest_fail if !user
dbnum,blnum = params[:dbnum].to_i, params[:blnum].to_i
return { rows: [] }.rest_success if !user.dashboardinfo || !user.dashboardinfo[dbnum] || !user.dashboardinfo[dbnum]['blocks'] || !(block = user.dashboardinfo[dbnum]['blocks'][blnum]) || !respond_to?("dashboard_type_#{block['type']}", true)
if params[:inbackground] == 'true'
t = Thread.new do
t.priority= -1
ret = method("dashboard_type_#{block['type']}").call(block['filters'], false, true)
ret.rest_success
end
else
ret = method("dashboard_type_#{block['type']}").call(block['filters'], false, false)
ret.rest_success
end
end
Of course the problem with this is that you get a bunch of dead threads building up as your server runs. And if you're working in a REST API (designed to be stateless), it might not be as simple as throwing your threads into an array and periodically cleaning them up.
Ultimately, I think, you should look into asynchronous job handlers. I've worked with sidekiq and had a decent time, but I don't have enough experience to give you a whole-hearted recommendation.

Ruby if statement with 3 options using a variable?

I have this line of code that only has 2 options. If it is Provider Payments then use the provider_payments_work_lists_path else use the duplicate_claims_work_lists_path. Now I want to include a potential 3rd path. if the name == "Reimbursed Claims" then path them to reimbursed_claims_work_lists_path. How can I do that? Currently I have:
url = (workList.work_list_name == "Provider Payments") ? provider_payments_work_lists_path : duplicate_claims_work_lists_path
Just use a case statement:
url = case workList.work_list_name
when 'Provider Payments'
provider_payments_work_lists_path
when 'Reimbursed Claims'
reimbursed_claims_work_lists_path
else
duplicate_claims_work_lists_path
end

Resources