List Collector variable not returning approver in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2024 02:03 AM
I have a list collector variable called application_name which refers to the service table. I want the managed_by person which is in the service table to be the approver. I am writing the below script but it is returning empty values
var approvers =[];
var service= fd_data._1__get_catalog_variables.application_name;
var gr=new GlideRecord('cmdb_ci_service');
if(gr.getValue(service))
{
var m=gr.getValue('managed_by');
approvers.push(m);
}
return "ApprovesAnyU[" +approvers.join(',') + "]";
This is returning correct approver if only 1 value is selected in the list collector variable but for more than one value it is returning empty approver.
I also tried using
Still returning empty values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2024 02:09 AM
What is the value of your variable when you check the execution details? It looks like you are checking the cmdb_ci_service records based on 1 sys_id, while your variable is a list, not a single record.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2024 02:12 AM
while I select 1 value in the list collector variable then it is returning one value.
If I select more than one value in list collector variable it returns empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2024 03:55 AM
Does this help:
(function() {
var approvers = [];
var serviceNames = fd_data._1__get_catalog_variables.application_name;
// Iterate through each selected application in the list
for (var i = 0; i < serviceNames.length; i++) {
var serviceName = serviceNames[i];
var gr = new GlideRecord('cmdb_ci_service');
if (gr.get('name', serviceName)) {
var manager = gr.getValue('managed_by');
if (manager) {
approvers.push(manager);
}
}
}
return "ApprovesAnyU[" + approvers.join(',') + "]";
})();
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark