The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Flow not retrieving Output value from Flow Action

Markell
Tera Guru

Hi Guys

 

I have an issue with Flow Designer where by I created an action within a flow. 

I know the Action is receiving the correct input values as they show on the Step Configuration when I test:

Markell_0-1675701740564.png

I know that in my Action the script is working and producing the outputs that I need when I test the action 

Markell_1-1675701847542.png

But what is not working is that when I run the test on the overall flow (which is meant to use the output values to send an email) the flow execution reads that the "Email has no recipients".

Markell_2-1675701923986.png

 

When I look at the outputs in the flow execution for my action, in this instance there are no outputs:

Markell_3-1675701986676.png

 

Can anyone point me in the right direction as to why the Action will display correct info when I test the action but when I test the overall flow that the action is in, then the Outputs cannot be retrieved?

 

Kind Regards

 

Markell

 



 

1 ACCEPTED SOLUTION

Markell
Tera Guru

Hi Guys so got this sorted with SN Support. They advised that the issue doesn't seem to be a problem with the input data, but does appear to be a known new bug, discovered recently on a previous case, and referred me to this knowledge article.

The fix was to change part of my code to retrieve the input value from:
var value = inputs.request_item;
grReq.addQuery('sys_id',value.);
to
grReq.addQuery('sys_id',value.getUniqueValue());

 

"It seems to be an issue how the Reference is passed to the subflow as input."

 

Posting this in the hope it helps someone else in future as I did not know you had to use getUniqueValue() to get the sys_id to pass the value in a flow (and that this was a previously known issue).

 

Regards

 

Markell

View solution in original post

10 REPLIES 10

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

You can see the scope and the accessibility if you click the three dots in the top-right of your action anc choose properties. You should see something like this:

 

LaszloBalla_0-1675789613486.png

 

What about the other thing I have mentioned - how is the flow run? The same way I mentioned above for Action properties, you can check the properties of the Flow and verify if 'Run As' is set to 'System User' or 'User who initiates the session'.

 

It's hard to think of anything else without seeing the actual flow and the actions. If everything is in order, it is usually just a data mapping issues, especially if your Action is working when tested separately.

My Action(s) Inputs:

Markell_0-1675779088055.png

Script:

(function execute(inputs, outputs) {
var value = inputs.request_item;
var grReq = new GlideRecord('sc_req_item');
grReq.addQuery('sys_id',value);
grReq.query();
if(grReq.next()){ 
var RSassigned = '';
outputs.ritm = grReq.getValue('number');
var ritm = grReq.getValue('number');


//**** gr get values from task----//
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',value);
grTask.addQuery('state','1').addOrCondition('state','-5').addOrCondition('state','2');
grTask.addQuery('active','true');
grTask.query();
if(grTask.next()){ 

if(grTask.assigned_to != ''){ 
RSassigned = '1';
} //***3

if(grTask.assignment_group != ''){ 
RSassigned = '2';
} //***4

if(RSassigned == '1'){
var grUsers = new GlideRecord('sys_user');
grUsers.addQuery('sys_id',grTask.assigned_to);
grUsers.query();
if(grUsers.next()){

outputs.assigned_to = grUsers.getValue('name');
outputs.email = grUsers.getValue('email');




if(RSassigned == '2'){ 

var grGroups = new GlideRecord('sys_user_group');
grGroups.addQuery('sys_id',grTask.assignment_group);
grGroups.query();
if(grGroups.next()){ 

outputs.assigned_to = grGroups.getValue('name');
outputs.email = grGroups.getValue('email');




//**** gr get values from approval----//
var grAppRec = new GlideRecord('sysapproval_approver');
grAppRec.addQuery('sysapproval.number',ritm);
grAppRec.addQuery('u_active','true');
grAppRec.addQuery('state','requested');
grAppRec.orderBy('sys_created_on');
grAppRec.query();
if(grAppRec.next()){ 

RSassigned = '3';

if(RSassigned == '3'){ 

var grAppUser = new GlideRecord('sys_user');
grAppUser.addQuery('sys_id',grAppRec.approver);
grAppUser.query();
if(grAppUser.next()){ 

outputs.assigned_to = grAppUser.getValue('name');
outputs.email = grAppUser.getValue('email');




})(inputs, outputs);

 

Output variables:

Markell_1-1675779231369.png

 

Action Outputs

Markell_2-1675779266053.png

 

 

Thanks in advance

 

 

grAppRec.addQuery('sysapproval.number',ritm);   may be ignored by GlideRecord due to there not being a ".number".   When part of a GR is in error, GR ignores it.  It could be always running RSassigned==3

Thanks for response.

If it was caused by such an error, why would the initial test in the action work (retrieve a value)?

Would seem odd. I do use that glide on the approval table allot as it took me a while to figure out how to get that field to work in a gliderecord

An invalid addQuery, is ignored.  The GR query will continue like it doesn't exist. You'll still get results, just a lot more.

Remember that you can dot walk.  
grTask.assigned_to.name.toString()  == grGroups.getValue('name');