If activity in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 02:19 AM
Hi, I have a IF activity that looks like this
Script:
workflow.scratchpad.result = ifScript();
function ifScript() {
var result = {crf_dev_role_auth_caller:false, crf_dev_role_auth_approver:false, crf_dev_role_watchlist:false, none:false};
if (JSUtil.notNil(workflow.scratchpad.trigger)) {
if (workflow.scratchpad.trigger.indexOf('crf_dev_role_auth_caller') > -1) {
result.crf_dev_role_auth_caller = true;
}
if (workflow.scratchpad.trigger.indexOf('crf_dev_role_auth_approver') > -1) {
result.crf_dev_role_auth_approver = true;
}
if (workflow.scratchpad.trigger.indexOf('crf_dev_role_watchlist') > -1) {
result.crf_dev_role_watchlist = true;
}
}
if (!(result.crf_dev_role_auth_caller || result.crf_dev_role_auth_approver || result.crf_dev_role_watchlist)){
result.none = true;
}
//gs.log('---> ' + result.red + ',' + result.blue + ',' + result.green + ',' + result.none,
// 'Playing With the If Activity.Validate Trigger');
return result;
}
Each condition properties looks like:
workflow.scratchpad.result.crf_dev_role_auth_caller == true
workflow.scratchpad.result.crf_dev_role_auth_approver == true
Now I need help to create a run script I think 1 run script to check for the results
for example if(workflow.scratchpad.result.crf_dev_role_auth_caller == true){
// insert a record in Auth caller table
}
if(workflow.scratchpad.result.crf_dev_role_auth_approver == true)
{
//insert record in auth appr table
}
I need help with right code to achieve the same as I am unsure if the conditions are correct
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 02:34 AM - edited ‎10-16-2023 02:37 AM
Hi @DB1 ,
You can use "switch activity" instead of if condition & try once. There you wont even need to perform scripting if we need to validate based upon variables present on form.
Mark my answer helpful & accepted if helps you answer your question.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 03:15 AM
what you wish to do with those variables?
Are those checkboxes in catalog item?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2023 03:26 AM
Yes they are checkboxes.
I need to insert records on each different table as mentioned above.
When Auth Caller is checked I need to insert on table 1
Similarly on other tables when other checkbox are selected it has to insert records accordingly