Using flow designer to set field value via script

JJG
Kilo Guru

Hello,

I have a flow in flow designer and I would like to set the "Opened for" field to be set to the current value of the "Opened by" field. I have been using the following script but it doesn't seem to work:

find_real_file.png

Both the open_for & the open_by fields are reference fields to the user table, is that why this is not working? How should I fix this? Any help is appreciated.

1 ACCEPTED SOLUTION

Solved: 

var shortDesc = fd_data.trigger.current.opened_by.getDisplayValue();
var desc ="New Hire Onboarding case for "+shortDesc;
return desc;

View solution in original post

7 REPLIES 7

Sebastian R_
Kilo Sage

You do not have to use the script for it. You can use the data pill picker to set your field easily based on your record.

https://developer.servicenow.com/app.do/app.do#!/lp/new_to_servicenow/app_store_learnv2_flowdesigner_madrid_using_flow_variables?v=madrid

thank you for your reply, I would like to know how to script it because I will need that knowledge for more complex flow problems.

current is not valid in the script. You can also drag and drop the data pill into the acript and then dot walk to your field.

I think normally there should be an example in the script field i you open it the first time.

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/administer/flow-designer/concept/inline-scripts.html

This was my flow script: 

var shortDesc = fd_data.trigger.current.opened_by;
var desc ="New Hire Onboarding case for "+shortDesc
return desc;
 
this was the outcome:
 
New Hire Onboarding case for [object GlideRecord]
 
any ideas?