- 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 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 12:58 AM
This is and condition or OR condition in script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 01:26 AM
Hello Ankur, Its failing.
I have used below script because this are all words which company name will contain.
answer = ifScript();
function ifScript(){
var val = current.var_employee_company_name.toString();
if(val.indexOf('Ventures') > -1 || val.indexOf('finance') > -1 || val.indexOf('fashion') > -1 || val.indexOf('lifestyle') > -1 || val.indexOf('leisure') > -1 || val.indexOf('MAF LEC') > -1 || val.indexOf('MAF LEC KSA') > -1 || val.indexOf('cinema') > -1){
return 'yes';
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 02:14 AM
Hi,
is workflow on some table?
is the field name correct? var_employee_company_name
Logic I shared is correct; you just want to use correct field name or variable name
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader