Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Object Glide Record in Flow Designer Scripting

Community Alums
Not applicable

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;



 

1.png

 

2.png

 

3.png

 

Regards

Suman P.

1 ACCEPTED SOLUTION

@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.

View solution in original post

6 REPLIES 6

Mr_X
Mega Guru

Hi @Community Alums ,

 

Instead of using gr.name can you try gr.getValue(‘name’);

 

Mayur2109
Kilo Sage

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

Amit Verma
Kilo Patron
Kilo Patron

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.

Community Alums
Not applicable

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.