ServiceNow EncodedURIComponent not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 08:54 AM - edited 11-06-2024 09:35 AM
Hello,
Need help with generating preview link with special characters(/,%,-,/,_ etc.,) on a custom form.
Preview link is not opening when condition is having special characters.
Thanks,
Swapna.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 10:22 AM
@Swapna Patiband To generate a preview link that works with special characters in ServiceNow, you need to URL-encode the link so that special characters are properly handled by the browser.
Encode special characters in the URL so that they do not interfere with the link generation. You can use the encodeURIComponent() if works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 06:40 AM
Thanks Abhay.
encodeURIComponent() is not working for all special characters like % , / , - , _ , : etc.,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 06:54 AM
@Swapna Patiband Can you pls share the code to verify.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2024 02:15 PM
// current.u_maint = "source=ABC XYZ^ORadditional_infoLIKEABCXYZ^metic_name=ab10-0814a-a% of available disk space"
var condition = current.u_maint;
var encodedCondition = encodedURIComponent(condition);
var almLink = gs.getProperty('glide.servlet.uri) + '/nav_to.do?uri=' + 'em_alert' + '_list.do?ysparm_query='+encodedCondition;
current.u_link = almLink ;