How to print the out put using commas in background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 03:20 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:05 AM
@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.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:10 AM
hai
can you tell me what is parent identifying field
please let me know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 07:40 AM
@sekhar6 On child table there must be some field which is referencing the parent table. The link between the child and parent table.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 03:26 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 04:15 AM
@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.
ServiceNow Community Rising Star, Class of 2023