flow designer script issue

- 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 03:52 AM
Maybe a silly question (I just briefly looked over the code yet): Why are you using a script instead of the OOB "Lookup Records" action?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 04:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2024 07:59 AM
Did you succeed? 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2024 04:19 AM
Hi @Community Alums
I recommend you after you have taken your data into variables, make sure that those data are also valid before doing another operation. You can do that by "gs.info()" function and if condition.