- 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 10:26 PM
Hi Ankur,
We are populating App names using script into a String field. So whenever we create a relationship between an application and server, then in the server record there is a field, and in that the applications will populate automatically with comma separated. But I want to populate them one below the other.
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 11:11 PM
Share the script here and did you make the field with length as 300 etc?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2022 11:28 PM
Hi Ankur,
if (grServ.getDisplayValue('u_rel_app') != relApp) {
grServ.u_rel_app = relApp;
grServ.update();
}
}
return true;
},
- 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-23-2022 01:55 AM
Thank you ABhijit