setting flow variable using a script

jonathangilbert
Kilo Sage

Hi All

I am trying to set a flow variable, by taking values from 2 catalog variables, but my script does not populate anything

I wish to take the 1st letter from the "First Name" variable and the whole value from the "Surname" variable, so that in the example John Smith would give a flow variable of "Jsmith"

This is the only line script I am using in the "Set Flow variable" action:-
fd_data.current.variables.first_name .substring(0,1) + fd_data.current.variables.colleagues_surname);

even if I simplify just to try and get the value from one of the variables, fd_data.current.variables.first_name; I dont get any populated value either.


What am I doing wrong?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update as this

fd_data.trigger.request_item.variables.first_name.toString().substring(0,1) + fd_data.trigger.request_item.variables.colleagues_surname;

regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

update as this

fd_data.trigger.request_item.variables.first_name.toString().substring(0,1) + fd_data.trigger.request_item.variables.colleagues_surname;

regards
Ankur

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

Good Afternoon Ankur,

 

I have updated with your line of script and it still returns back a blank entry

This is the script entry in the flow

find_real_file.png

This is where the description should be updated with the flow variable 

find_real_file.png

 

There are no logs against the flow variable once it has executed

find_real_file.png

 

Many Thanks

jonathangilbert
Kilo Sage

Hi Ankur,

 

I have sorted it, usign what you had supplied but also adding in the variable dun

 

var dun = "DUN" + fd_data.trigger.request_item.variables.colleagues_first_name.toString().substring(0,1) + fd_data.trigger.request_item.variables.colleagues_surname;
 
return dun;
 
 
Thank you so much for your help again