Fetch URL param values from a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 02:13 AM
1.
var url = new GlideURL(urlString);
var value = new URLSearchParams(url).get('sysparm_query');
gs.info(value);
2.
var parmVal = url.getParameter('sysparm_query');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 02:45 AM
@NehaA3677346693 - I believe GlideURL works only on client side scripts. For me it worked on client script and not in the background scripts
See below:
If you have access to this KB then view here: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783157
Please mark this correct or helpful if it works for you.
Cheers!!
Anu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 02:48 AM
any idea how we can do in background script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 02:56 AM
Hi @NehaA3677346693 ,
On any form or screen, press ctrl + shift+ j. This will open java script executor. there you can paste your code and run it. Replace gs.info with alert to print anything.
The GlideURL API is client side and only can be use in client script, ui policy or client side code for UI Action.
It can be utilized in server side before not in background script.
Please mark this correct or helpful if it works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 03:44 AM
@Mehta Thanks for your response. I am looking for a solution to run in background script as after fetching the values from url I need to perform some insert operations as well.