- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 07:26 AM
Hi everyone,
There is a string field holding multiple values with comma separated. I want to show the values one below the other instead of comma separated.
Taking the values into an array, and pushing those values one by one into that field like, once we push first object of the array into string field, and while we push the second object of the array into the string field, can we print that below the first value with \n ?
How can we do this? using any onload Client script?
Can someone help me to achieve this with code?
Regards,
Pallavi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 12:05 AM
Hi,
Try below script,
updateABC: function(serv, relApp) {
var grServ = new GlideRecord('cmdb_ci');
grServ.addEncodedQuery('sys_id=' + serv);
grServ.query();
if (grServ.next()) {
if (grServ.getDisplayValue('u_rel_app') != relApp) {
grServ.u_rel_app = relApp.replaceAll(",","\n");
grServ.setWorkflow(false);
grServ.update();
}
}
return true;
},
Let me know if you have any further questions.
Please mark this as Correct or Helpful based on the impact.
Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 07:49 AM
Hi Pallavi,
Change the String field length to more than 255 characters. See the image below.
It will look like this.
Then you can utilize the following script.
var arr = [1,2,3,4,5,6,8];
gr.setValue('<your_fiield_name>', arr.join('\n'));
gr.update();
hopefully, this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 09:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2022 12:51 AM
How do you want this to be achieved ?
From where you will get or are getting values ?
What is the format/structure/datatype of those values ?
A sample would be useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 09:50 PM
Hi,
if you make it with larger length then user can enter the new line for each values.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader