- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 01:41 AM
Hi Community,
I have a BR using which i am removing the spaces from a field. First the data is getting being loaded via scheduled job. Once its loaded an after insert/update BR will work and it will remove the spaces from that field.
Here is the code, i thought it was working fine in background script but now it didnt removed spaces from 2 records.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 01:57 AM
okay got it
then do this and it will replace 1 or more whitespaces
record.abc = record.abc.toString().replace(/\s+/g, '');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 01:50 AM
why not handle it during data load itself?
try this
var record = new GlideRecord('xyz');
record.query();
while (record.next()) {
record.abc = record.abc.toString().replace('ABCD', '');
record.abc = record.abc.toString().replaceAll(" ", '');
record.setWorkflow(false); //Do not run business rules
record.autoSysFields(false); //Do not update system fields
record.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 01:55 AM
Space can be more. Here you have given only 1 space. Will it work if there are more spaces in the field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 01:57 AM
okay got it
then do this and it will replace 1 or more whitespaces
record.abc = record.abc.toString().replace(/\s+/g, '');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 09:17 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader