- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-17-2022 12:10 PM
Hello,
I have a requirement to trigger catalog task in workflow if Department Variable (referencing to cmn_department) contains value "Information Technology" or "GST" then it must trigger the catalog task oresle no
I have written below If condition advanced script but its failing
Reference variable Department has Question and Name value both as Department. Image attached
function ifScript() {
var Department = current.variables.Department.getDisplayValue();
if (Department.toString().indexOf('Information Technology') >-1 || Department.toString().indexOf('GST') >-1){
return 'yes';
}
return 'no';
}
Please advice.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-18-2022 01:02 AM
Hello
Then try below script
answer = ifScript();
function ifScript() {
var dept = new GlideRecord('cmn_department');
dept.addQuery('sys_id',current.variables.Department);
dept.query();
if(dept.next())
{
if(dept.name.indexOf("Information Technology") || dept.name.indexOf("GST"))
{
return 'yes';
}
else
{
return 'no';
}
}
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-17-2022 12:33 PM
Hello
Is it a reference field or a list collector type variable?
Also make sure you put this line before your function
answer=ifScript();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-17-2022 12:52 PM
Please use sys_ids of department records instead of names
answer = ifScript();
function ifScript() {
var spl = current.variables.Department.toString().split(',');
if (spl.indexOf('Information technology department record sys_id')>-1 ||spl.indexOf('GST department record sys_id')>-1 ) {
return 'yes';
}
return 'no';
}
Please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-17-2022 01:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-17-2022 01:50 PM
answer = ifScript();
function ifScript() {
if( current.variables.Department =="Information technology department record sys_id" || current.variables.Department == 'GST department record sys_id')
{
return 'yes';
}
else
{
return 'no';
}
}
Please mark my answer correct if it helps you