How to use Requested for field of Requested item in Flow Designer Its giving Error that Undefined.

Balaraju K B
Tera Expert

Hi Team,

I have a requirement that Based on Requester's last name starting Alphabet i Need to assign the catalog task to Specific Assignment Group (they have given 3 Assigment Groups)

Condition :

(if lastname (A-I or N) ASSIGMENT GROUP 1)

(if lastname (J-Q or R ASSIGNMENT GROUP 2)

(if lastname (S-Z ASSIGNMENT GROUP 3)

This script is wirking fine in Workflow but its not working in Flow designer

In Flow designer it's showing undefined input 'assignment_group' error

How can i implement this below script in Flow designer. 

var lastname=current.request.requested_for.last_name;
var split_lastname=lastname.substr(0,1);
if(split_lastname.toLowerCase()=='a'||'b'||'c'||'d'||'e'||'f'||'g'||'h'||'i'||'n')
{
task.assignment_group='802cb4b3db069850e783f3671d961969';//Assignment grp 1 
}

else if(split_lastname.toLowerCase()=='j'||'k'||'l'||'m'||'o'||'p'||'q'||'r')
{
task.assignment_group='b14c7877db069850e783f3671d9619f0';//Assignment grp 2

}
else if(split_lastname.toLowerCase()=='s'||'t'||'u'||'v'||'w'||'x'||'y'||'z')
{
task.assignment_group='875cf4f3db069850e783f3671d96193c';//Assignment Group 3

}

 

Thanks in Advance

Balaraju

1 ACCEPTED SOLUTION

HI,

Couple of improvements to script.


For example:

var lastname=current.request.requested_for.last_name; Replace it with

var lastname=fd_data.trigger.current.request.requested_for.last_name;


Thanks,

Ashutosh

View solution in original post

6 REPLIES 6

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

Show me where you wrote this script on flow designer. 

 

Thakns,
Ashutosh

Please take a look at the flow designer Ashutosh.

 

HI,

Couple of improvements to script.


For example:

var lastname=current.request.requested_for.last_name; Replace it with

var lastname=fd_data.trigger.current.request.requested_for.last_name;


Thanks,

Ashutosh

@Balaraju K B 

this should work in the script section

1) you need to select the data pill corresponding to that RITM record

2) Also use return statement to return the group sys_id

3) you need to compare the variable for each value

try updated script below

var lastName = fd_data.trigger.request_item.request.requested_for.last_name;

var split_lastname = lastname.substr(0,1);

split_lastname = split_lastname.toLowerCase();

if(split_lastname == 'a'|| split_lastname == 'b'|| split_lastname == 'c'|| split_lastname == 'd'|| split_lastname == 'e'|| split_lastname == 'f'|| split_lastname == 'g'|| split_lastname == 'h'|| split_lastname == 'i'|| split_lastname == 'n')
{
 return '802cb4b3db069850e783f3671d961969';//Assignment grp 1 
}

else if(split_lastname == 'j'|| split_lastname == 'k'|| split_lastname == 'l'|| split_lastname == 'm'|| split_lastname == 'o'|| split_lastname == 'p'|| split_lastname == 'q'|| split_lastname == 'r')
{
return 'b14c7877db069850e783f3671d9619f0';//Assignment grp 2
}
else if(split_lastname == 's'|| split_lastname == 't'|| split_lastname == 'u'|| split_lastname == 'v'|| split_lastname == 'w'|| split_lastname == 'x'|| split_lastname == 'y'|| split_lastname == 'z')
{
return '875cf4f3db069850e783f3671d96193c';//Assignment Group 3
}

Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader