- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2020 04:19 AM
How to get current URL link in an variable?
Requirement is from incident form through UI action url redirected to record producer which has to create change record.
Once change record created, Incident form has to be get updated with caused_by related reference field to change record.
Can you please help to get the URL link in an varaible that redirects to record producer.
Thank you
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2020 06:46 AM
Hi,
you need to write onLoad catalog client script to get the url parameter value
Is the extra parameter in url with name as sys_id ?
if yes then try this
function onLoad(){
var url = top.location.href;
var value = new URLSearchParams(url).get("sys_id"); // give here the parameter name
g_form.setValue('hidden_variable', value);
}
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
‎08-26-2020 04:26 AM
Hi Ilavarasu,
can you please clarify the below points.
1) is your requirement is to create a change record from incident form.
2)post change creation, do you want to update a field in incident form.
3) Why you have to redirect to record producer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2020 04:29 AM
Hi,
you will have to pass the incident sys_id from the UI action to the record producer form.
Store that in the hidden variable using onLoad client script
In the record producer script you can use this script
var inc = new GlideRecord('incident');
inc.get(producer.incVariable);
inc.caused_by = current.sys_id;
inc.update();
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
‎08-26-2020 06:22 AM
Thank you Ankur.
I have passed the incident sys_id in redirect URL(UI Action). Now I got struck in getting the current URL in a variable for getting the incident sys_id to update in the invisible variable. can I have the function that can get current URL in a variable.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2020 06:46 AM
Hi,
you need to write onLoad catalog client script to get the url parameter value
Is the extra parameter in url with name as sys_id ?
if yes then try this
function onLoad(){
var url = top.location.href;
var value = new URLSearchParams(url).get("sys_id"); // give here the parameter name
g_form.setValue('hidden_variable', value);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader