If activity multiple conditions usage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 08:27 PM - edited 12-19-2023 06:43 AM
Hi everyone,
I have this requirement, in which i have to use multiple conditions in if loop.
For e.g., their are three conditions in if loop A, B, C(No). and their are resembling checkboxes on the RITM record as well for those conditions. If any of those checkboxes are checked then the workflow should pass through only those conditions resembling the checked fields on the ritm record.
Below is the script i am using in advanced script of if activity:
answer = ifScript();
function ifScript() {
var currentRecord = new GlideRecord('sc_req_item');
currentRecord.addQuery('sys_id', current.sys_id);
currentRecord.query();
gs.info('check here');
if (currentRecord.next()) {
var fieldValue1 = currentRecord.variables.checkbox_field_name1;
var fieldValue2 = currentRecord.variables.checkbox_field_name2;
if (fieldValue1 == true) {
gs.info(' checkbox_fieldname1 condition met');
workflow.scratchpad.branchToTake = "Condition name resembling the checkbox_field_name1";
return 'yes';
}
if (fieldValue2 == true) {
gs.info('checkbox_field_name2 condition met');
workflow.scratchpad.branchToTake = "Condition name resembling the checkbox_field_name2";
return 'yes';
} else {
gs.info('neither of the condition met');
workflow.scratchpad.branchToTake = "No";
return 'No';
}
}
gs.info("Exiting script.");
}
the script seems to be working fine as i tested it in BG script and according to the sys_id of ritm i provide it is entering the right if loop and printing the gs.info accordingly. But the problem i am facing is the activity is always giving result as no and thus passing through only No condition.
OR
Do i need to create a run script with multiple conditions? or any other activity that can help me complete this requirement?
Also the workflow condition record for both the conditions, do i need to do anything in there?
Thank you.