
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 03:33 AM
Hi,
I have a script with me, I made changes to the existing scripting to suit my requirement, so I am getting [Object GlideRecord]. Can you please correct the script. 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 shortDescr;
*/
var action = fd_data._1__get_catalog_variables.action;
var servers_string = fd_data._1__get_catalog_variables.server_s; //string
var service_acc = fd_data._1__get_catalog_variables.service_account;
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();
while(gr.next())
{
servers_name_arr.push(" " + gr.name.toString());
}
}
var msg = action+" BoKS Service Account " + service_acc + "with Servers "+ "("+servers_name_arr+")";
return msg;
Regards
Suman P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 05:02 AM
@Community Alums
service_account field is a reference field, when you use it directly, you are getting a GlideRecord object. You need to dot-walk one step into the reference field like
var service_acc = fd_data._1__get_catalog_variables.service_account.user_name; // Assuming we have user_name field
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 03:44 AM
Hi @Community Alums ,
Instead of using gr.name can you try gr.getValue(‘name’);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 03:47 AM
Hi @Community Alums ,
Try JSON.stringify(servers_name_arr) in var msg.
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Mayur Shardul
ServiceNow Rising Star 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 03:59 AM
Hi @Community Alums
Add .toString() to your array servers_arr_name and try
var msg = action+" BoKS Service Account " + service_acc + "with Servers "+ "("+servers_name_arr.toString()+")";
return msg;
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2024 04:39 AM
Hi @Mayur2109 @Amit Verma @Mr_X ,
I am sorry the question is too big to concentrate for any. The problem i am getting is with respect to service account and not servers. I am able to display the values of the servers well. For the service_account part, I am facing the issue. It is showing as [Object GlideRecord]
Regards
Suman P.