I write the blow code in if activity in workflow. It is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 08:52 PM
I want to divide if activity in three part.. OSvalue is passed the correct value but if activity not passed the way.
I write the three conditions for this activity:
activity. result=='win10'
activity. result=='win11'
activity. result=='blank'
The code is :
var OSvalue = workflow.scratchpad.Operatingsystem;
gs.log('Chandra@@@@' + OSvalue);
answer = ifScript();
function ifScript() {
if (OSvalue.includes("Windows 10")) {
return 'win10';
}
if (OSvalue.includes("Windows 11")) {
return 'win11';
} else {
return 'blank';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:19 PM
Hello @Chandra18
Can you share if possible some screenshot of workflow and "if activity"
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 09:26 PM
Hi @Chandra18 ,
I think the IF activity in the workflow should return either 'yes' or 'no' in orde to move forward. Based upon yes or no u can decide what u need to do.
So ur code should look like
var OSvalue = workflow.scratchpad.Operatingsystem;
gs.log('Chandra@@@@' + OSvalue);
answer = ifScript();
function ifScript() {
if (OSvalue.includes("Windows 10")) {
return 'yes';
}
if (OSvalue.includes("Windows 11")) {
return 'no';
} else {
return 'no';
}
}
From the above code there are 2 'no' so what u can do is u can add 1 more if to the output of no n again check only for no part of the logic.
Thanks,
Danish