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 05:05 AM - edited 12-19-2022 05:06 AM
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 03:50 AM
@sekhar6 , use join method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 04:53 AM
Hai i want to print the out put on the parent record .
the parent field back end value is "u_specific_location"
how to pust out put value in to the parent table field "u_specific_location"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 05:44 AM
@sekhar6 gr.addQuery('901cf7a91bf715105d37fc8f034bcb3a');
This line is wrong.
you must have some field in addQuery function. its just sys_id.
AND
after the below line just add print statement dont need for loop
arr = arrayUtil.unique(arr);
gs.print(arr.toString())
Please mark as helpful based on impact
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 05:53 AM
hai ,
i was using this script because to clear the duplicate values and print he data
var arr= [];
var gr = new GlideRecord ('u_item_changes_volume');
gr.addQuery('u_event',current.sys_id);
gr.query();
while(gr.next()){
var gv = gr.u_location.trim();
arr.push(gv);
}
var arrayUtil = new ArrayUtil();
arr = arrayUtil.unique(arr);
arr.push("u_specific_location");
current.u_specific_location =(arr.join(","));
//gs.print (arr.join(","));
i have written this on the child table business rule , the script is working fine ,my target is to push the out put data in to the parent record field ,
help me on this,
thank you,
sekhar.