Quebec - Flow Designer and List Collector Variables

Herb2
Tera Expert

In previous releases of ServiceNow the List Collector variable in Flow Designer was treated as a comma separated list of sys_ids. This caused some issues with Flow Designer that required using Custom Actions. I have several custom actions that use a List Collector as the input and then look up glide records on the sys_user table for example to generate a list of user's managers. My actions no longer work in Quebec, so it appearrs that list collectors are no longer working as comma separated lists. What type of variable are they treated as in Flow Designer, and how can i parse these lists so that i can iterate over them in my custom actions.

Here is a very simple custom action which works in a flow in Paris, and works when i use the Test function in flow designer in our Development instance which is on Quebec. However when i use this action in a flow in Quebec, the outputs for the action are blank. 

(function execute(inputs, outputs) {
var users = inputs.Users.toString().split(',');
var mgr_list = [];
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('sys_idIN'+users);
gr.query();
while (gr.next()) {
mgr_list.push(gr.manager.getValue('sys_id'));
}
  mgr_list = mgr_list.toString();
  mgr_list = mgr_list.split(',');
  outputs.managers = mgr_list;
  
})(inputs, outputs);

Here it is used in a flow, and does not successfully return the Manager objects from the inputted users.

find_real_file.png

Here is the action

find_real_file.png

Here is a successful execution of the Test function. 

find_real_file.png

1 ACCEPTED SOLUTION

The issue is identified an a product defect in Quebec release.

PBB# PRB1502254

Workaround: Check below SN Article.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0831321

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0827213

 

Thanks,

Rohit

View solution in original post

16 REPLIES 16

Allen Andreas
Administrator
Administrator

Hello,

Your first screenshot shows it as array.string, which I would say is correct...the second screenshot shows array.object, which is incorrect. From this it says Array.Object and that's not what's included in your array, it's string values from a Glide Object, can you change that to Array.String, which is what it is or will be in the end?

Then you could/should be able to chop the script down even further to just this:

(function execute(inputs, outputs) {
var users = inputs.Users.toString().split(',');
var mgr_list = [];
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('sys_idIN'+users);
gr.query();
while (gr.next()) {
mgr_list.push(gr.manager.getValue('sys_id'));
}
outputs.managers = mgr_list;
})(inputs, outputs);

As it's already an array, already in string by using getValue and should already be comma separated due to the push.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hey Allen,

Thanks for the tip on cleaning up the script.

As far as using an array of objects, the actions that i have created exist in my Prod environment and use array.string as their output are working in Paris. However those actions no longer work in my Development instance which is on Quebec, which is why i began to fiddle with them. 

I found this question and saw mention of this issue in a couple of other questions relating to List Collector variables in Flow Designer on Quebec. The suggested fix for an action that uses a List collector as an input and outputs an array is to change the output array type from array.string to array.object. It appears that something has definitely changed in how these variables are treated by Flow Designer in Qubec so i'm trying to understand what that is, and how to repair my actions. 

I checked and hadn't published the change that I had made in my action changing the output from array.string to array.object. However, i published that change in my flow and had the same result, so i can say that this action does not work with either array.object or array.string as the output type. 

find_real_file.png

 

find_real_file.png

Hello,

I'm not sure. I think you may need to look over your setup again.

Just for testing, I created an action with just a script step to see if I could get an array to result in the output and I was successful. This is just an example, but:

(function execute(inputs, outputs) {
var array = [];
  var gr = new GlideRecord('sys_user');
gr.addEncodedQuery('nameLIKEJames');
gr.query();
while (gr.next()) {
array.push(gr.getValue('sys_id'));
}
outputs.managers = array;
})(inputs, outputs);

This is more about the concept, but I would double-check your script and possible add some log statements to ensure it would actually net you results.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

Not too sure, I'd recommend double-checking everything, here's what I did and it works for me:

  • Created a catalog item with just one variable: list collector
  • Create a test flow with a custom action with setup such as:

find_real_file.png

find_real_file.png

find_real_file.png

Works for me:

find_real_file.png

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!