
- 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 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 05:16 AM
Hi @Community Alums ,
Your code required little correction like below.
Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.