- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 10:54 PM
Below is my script which i am using in the if activity of workflow,this workflow runs on Requested item table
I have a catalog variable project_id, Iwant to check if the value in project_id contains INT then only if part should get executed,but this code is not working
answer = ifScript();
function ifScript() {
if (current.variables.project_id.contains('INT')) {
return 'yes';
}
else{
return 'no';
}
}
Kindly try to fix my code.so i can proceed further.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 11:38 PM
Hi Abhishek,
Below is the sample code
answer = ifScript();
function ifScript() {
if (current.variables.project_id.toString().indexOf('INT') > -1 || current.variables.project_id.toString().indexOf('PRE') > -1 || current.variables.project_id.toString().indexOf('REF') > -1 ) {
return 'yes';
}
else{
return 'no';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 11:02 PM
Hi Abhishek,
can you update code as below; you can use indexOf() function
answer = ifScript();
function ifScript() {
if (current.variables.project_id.toString().indexOf('INT') > -1) {
return 'yes';
}
else{
return 'no';
}
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
03-17-2020 11:30 PM
Thanks Ankur for the quick reply
One more thing is that i want to add multiple conditions in if block,like project_id having any one these INT,PRE,REF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2020 11:38 PM
Hi Abhishek,
Below is the sample code
answer = ifScript();
function ifScript() {
if (current.variables.project_id.toString().indexOf('INT') > -1 || current.variables.project_id.toString().indexOf('PRE') > -1 || current.variables.project_id.toString().indexOf('REF') > -1 ) {
return 'yes';
}
else{
return 'no';
}
}