How to pass reference field from UI action to subflow

Shubham15
Kilo Contributor

I need to pass a reference field of sys_user_group table to my subflow. So for that I have tried using :-

var inputs = {};

var group = current.group; (group is a reference field for sys_user_group table.)

inputs['group'] = group;

sn_fd.FlowAPI.executeSubflow('x_797879_l_d_relea.create_product_and_release', inputs);

But it shows me this exception :- com.snc.process_flow.exception.ProcessAutomationException: Invalid GlideRecord input format found

I have also tried with sys_id i.e. 

var group = current.group.sys_id;

but still it shows same exception.

 

Can anyone help please ? 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

did you try passing hard-coded sysId

Regards
Ankur

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

Chandu Telu
Tera Guru
Tera Guru

Hi Shubham,

 

Sometime we are facing the issue with references try the below code it may help you

 

var inputs = {};

var group = current.getValue(group); (group is a reference field for sys_user_group table.)

inputs['group'] = group;

sn_fd.FlowAPI.executeSubflow('x_797879_l_d_relea.create_product_and_release', inputs);

 

Thanks

Chandu Telu

OlaN
Giga Sage
Giga Sage

Hi,

If you need to pass a reference to a GlideRecord object as input to a Flow, a SysID will not work, because it is a string.

So change your code to something like this:

var inputs = {};

var groupID = current.group; // get the sysID of the group
var groupGR = new GlideRecord('sys_user_group');
groupGR.get(groupID);  // get the reference, the group record

inputs['group'] = groupGR;