- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 01:15 AM
Hi All,
I am having multiple if conditions such as if Keyboard needed is selected as Yes, then in the run script , I want to consume a keyboard record and assign to requester.
If mouse needed is selected as Yes, then in the run script , I want to consume a mouse record and assign to requester.
If Webcam needed is selected as Yes, then in the run script , I want to consume a webcam record and assign to requester.
So, for the keyboard, the item name is Ergo Keyboard 123, for the mouse, the item name is Mouse CPA1
So, I am thinking to use a single run script but pass these values from if condition to run script. How it is possible.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 06:09 PM - edited 02-08-2024 06:10 PM
Hi @Renu9 in this cases, instead of while/switch, create a run script and check all the variable value and store it in different scratchpad variables/activity result and in next run script you can check these
if (current.variables.var_name == 'value1') {
activity.result = 'value1';
} else if (current.variables.var_name == 'value2') {
activity.result = 'value2';
}
else if (current.variables.var_name == 'value2' && current.variables.var_name == 'value1') {
activity.result = 'value3';
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 04:58 PM
HI @Renu9 switch statement will execute based on the choice selected, if you still want to use if, you can use. In your screen shot the 1st if statement, if keyboard is not selected then the "no" option should point to the next if statement. which you have left blank so in this case the if is not moving to next statement.
example
1st statment:
keyboard selected ? Yes --> run script
No --> point to next if statement
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 05:23 PM
Hi @Harish KM
In this case i have to run all the if statements . Because the user can request for keyboard mouse webcam etc etc. so if i keep if else condition then if keyboard satisfied it is not going to mouse or webcam part. So if else wont work
in switch case can u help me with that. Because if i use switch block it is displaying the choices in that variable .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 05:26 PM
Hi @Renu9 switch also will execute either one. May I know your use case ? what needs to be done?
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 05:32 PM
Hi @Harish KM
my use case is like when new user joined into the company he will be requesting for laptop keyboard mouse webcam all these items
so if he selects all these consumables then when the request is closed complete then quantity of 1 will be reduced from the consumable table
so there is a chance he selects all items right
so in this case if else is not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 06:09 PM - edited 02-08-2024 06:10 PM
Hi @Renu9 in this cases, instead of while/switch, create a run script and check all the variable value and store it in different scratchpad variables/activity result and in next run script you can check these
if (current.variables.var_name == 'value1') {
activity.result = 'value1';
} else if (current.variables.var_name == 'value2') {
activity.result = 'value2';
}
else if (current.variables.var_name == 'value2' && current.variables.var_name == 'value1') {
activity.result = 'value3';
}
Harish