flow designer script issue
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 03:41 AM
Hi,
I have written some code to get the list of IT Managers of the servers. I am not getting any output. Kindly help.
/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**Order number is offset by +1 in Error Handling Section.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc
*/
var action = fd_data._1__get_catalog_variables.action;
var requested_for = fd_data._1__get_catalog_variables.requested_for_user.sys_id;
var servers_string = fd_data._1__get_catalog_variables.server_s;
var servers_arr = servers_string.split(","); //array
var servers_name_arr = [];
for(var i = 0;i<=servers_arr.length;i++)
{
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('sys_id',servers_arr[i]);
gr.query();
if(gr.managed_by != " "){
while(gr.next())
{
if(gr.managed_by != requested_for){
servers_name_arr.push(gr.managed_by.name.toString());
}
}
}
}
var stringNames = servers_name_arr.toString();
var msg = "Next step: Your request requires approval from IT Manager(s) - " + stringNames;
return msg;
Regards
Suman P.
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 04:30 AM
Hi @Community Alums
Your if condition if(gr.managed_by != " ") should be inside the while loop. Without actually moving to next record object you cant really fetch the managed_by value.
Please mark my response as accepted solution if it was helpful.
Thanks
Nootan