- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 12:28 AM
Hello,
I want to use if condition based on value populated in var_employee_company_name.
If the value contains any of the below word it should skip further task which I can skip based on Yes/NO output of if check
I need help to write the script i.e. if var_employee_company_name contains Leisure or finance or lifstyle or ventures it should be Yes value orelse No
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 12:41 AM
Hi,
something like this if it's a field
if it's a catalog variable and you are using workflow on RITM then use this
var val = current.variables.var_employee_company_name.toString();
answer = ifScript();
function ifScript(){
var val = current.var_employee_company_name.toString();
if(val.indexOf('Leisure') > -1 || val.indexOf('finance') > -1 || val.indexOf('lifstyle') > -1 || val.indexOf('ventures') > -1){
return 'yes';
}
return 'no';
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 07:19 AM
Hi,
you want to search for exact value or contains?
because for contains the script should work fine
try to add some gs.info()
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2022 03:26 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 08:00 AM
Hope you are doing good.
Did my reply answer your question?
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 03:51 AM
Hi
Please use the script shared below:
answer = ifScript();
function ifScript(){
var getVariable = current.variables.VariableName.getDisplayValue().toString();
if(getVariable.indexOf('Ventures') > -1 || getVariable.indexOf('finance') > -1 || getVariable.indexOf('fashion') > -1 || getVariable.indexOf('leisure') > -1){
return 'yes';
}
return 'no';
}
Replace Variable Name with your correct Variable Name in script above
Similarly add other OR conditions for the values you need to validate and see if this works.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke