If condition in workflow, If variable contains value (X or Y) it must trigger catalog task

Ankita Gupte
Kilo Sage

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 attachedfind_real_file.png

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.

1 ACCEPTED SOLUTION

Hello @Ankita Gupte ,

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

 

View solution in original post

9 REPLIES 9

Mohith Devatte
Tera Sage
Tera Sage

Hello  @Ankita Gupte ,

Is it a reference field or a list collector type variable?

Also make sure you put this line before your function

answer=ifScript();

 

Mohith Devatte
Tera Sage
Tera Sage

@Ankita Gupte if its a list collector field please change the script to below

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

Hello Mohith, Its reference field as mentioned in question it refers to cmn_department table.

@Ankita Gupte  please ignore above script and  use below script

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