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

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

Runjay Patel
Giga Sage

Hi @Community Alums ,

 

Your code required little correction like below.

RunjayPatel_0-1729167350638.png

 

Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.