- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 02:00 AM
Want to remove first white space of short discription
suppose i give short discription ---> test then i want to remove the white space before the test
Also want to remove all incident short discription white spaces.
Could you please help me about this.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 02:08 AM
Hi,
for new records you can use before insert/update BR and use trim() method
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.short_description = current.short_description.trim();
})(current, previous);
for existing records you can run fix script and run it once.
updateRecords();
function updateRecords(){
try{
var gr = new GlideRecord("incident");
gr.query();
while (gr.next()) {
gr.short_description = gr.short_description.trim();
gr.update();
}
}
catch(ex){
gs.info(ex);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 02:07 AM
Hi,
you can use trim() method and it will remove any leading or trailing spaces
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 02:08 AM
Hi,
for new records you can use before insert/update BR and use trim() method
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.short_description = current.short_description.trim();
})(current, previous);
for existing records you can run fix script and run it once.
updateRecords();
function updateRecords(){
try{
var gr = new GlideRecord("incident");
gr.query();
while (gr.next()) {
gr.short_description = gr.short_description.trim();
gr.update();
}
}
catch(ex){
gs.info(ex);
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2022 02:53 AM
Thank you for your response. Its working as expected.
Regards
Aditya