- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 06:35 AM
I have a "Project" table that has a column called "Policies" that is a List of "Policy". I wrote a flow whose trigger is the creation of a new Project. The flow passes Trigger->Project Record->Policies to an action. This action has an input named "policies" that is of type "List.Policy". A script projects this list:
(function execute(inputs, outputs) {
var policies = inputs.policies;
outputs.policy_names = '';
while (policies.next()) {
outputs.policy_names += '<br/>' + policies.getDisplayValue();
}
})(inputs, outputs);
This works fine if the list contains two or more policies, but if there is only one, no policy names are generated. What am I doing wrong?
Thanks!
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 01:59 AM
You are doing nothing wrong. This is known issue I have reported this to HI more than 8 months ago.
Still not answer on when it will be fixed. Seems it's not really a priority for ServiceNow team.
You need to the manual workaround:
if(inputs.policies.getRowCount() == 1){
gs.info(inputs.policies);
}
else{
while(inputs.policies.next()){
gs.info(inputs.policies);
}
}
Hope that helps
Jozef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 01:59 AM
You are doing nothing wrong. This is known issue I have reported this to HI more than 8 months ago.
Still not answer on when it will be fixed. Seems it's not really a priority for ServiceNow team.
You need to the manual workaround:
if(inputs.policies.getRowCount() == 1){
gs.info(inputs.policies);
}
else{
while(inputs.policies.next()){
gs.info(inputs.policies);
}
}
Hope that helps
Jozef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 02:10 AM
Hi Chris,
you will have to convert the array of String to Array
please check below links for help
How to iterate an Array.String in the flow designer?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 07:28 AM
Thank you both!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 07:42 AM
Hi Chris,
So what was the solution/workaround
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader