How to print the out put using commas in background script

sekhar6
Tera Contributor

Hai all,

 I have a small doubt ,How to print the data using comma in the background script 

out put is

sekhar

chandu 

power

i want to print as 

sekhar,chandu,power.

 

 

thank you

sekhar.

 

14 REPLIES 14

@sekhar6 Oh ok.

 

Then instead of current.u_specific_location =(arr.join(",")); you must write below

 

var parentGr = new GlideRecord('<PARENT TABLE NAME>');

if(parentGr.get(current.<PARENT IDENTIFYING FIELD>)){

parentGr.u_specific_location =(arr.join(","));

parentGr.update();

}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

hai 

can you tell me what is parent identifying field 

please let me know

@sekhar6 On child table there must be some field which is referencing the parent table. The link between the child and parent table.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

RaghavSh
Kilo Patron

Are you getting data from some table? it is usually printed with a contact operator "+";

example: 

var num;

var inc = new GlideRecord('incident');

inc.addActiveQuery();

inc.query();

while(inc.next())

{

num = inc.number+","+num;

}

gs.print(num);


Raghav
MVP 2023

jaheerhattiwale
Mega Sage
Mega Sage

@sekhar6 Add values to an array like

 

var arr = ["sekhar","chandu","power"];

 

then print array

 

gs,print(arr.toString());

 

Please mark as correct answer if this solves your issue.

 

 

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023