How to check and replace UTF BOM characters in a String
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 03:40 AM - edited 11-17-2022 03:46 AM
How to check and replace UTF BOM characters in a ServiceNow String
We have found that while using flow designer to send data via web service integrations or doing general string data processing an unprompted UTF-8 BOM character is added by the flow designer.
This can break 3rd party systems integrations or a general nuisance while working with strings.
You can use the below code to check for and replace these UTF-8 BOM characters and create a sanitized data input for your flow to work flawlessly J
var aa = '0014�'; // String input
aa = aa.replace(/^\uFEFF/gm, "").replace(/^\u00BB\u00BF/gm,"");
for(var i = 0;i<aa.length;i++){
console.log("Test:" + aa[i]);
}
Happy CODING 😉
- 1,586 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 11:42 AM
I noticed that concatenating using pills adds unexpected and unwanted BOM characters. I wonder why that happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2022 09:37 AM
Yes!! Thank you. That is a problem. I am not sure when this started but it is big problem when building payloads for third parties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 03:46 AM
Looks to be an issue with using Chromium based browsers with flow designer. See this KB: Using flow designer in Chromium based browsers (eg. Chrome 105, Microsoft Edge 105 etc.) causes unex...