Fetching values from URL - Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 12:38 AM
I have to fetch values from the URL (sc_req_item & sysID next to it) and set it in Table field "source_table" & Document ID field "source_record" on the form respectively.
Sample URL as follows:
I'm tried following method but not sure how to use it exactly.. I used the same method for UI16 and it worked as expected
var gURL = new GlideURL();
gURL.setFromCurrent();
- Labels:
-
Agent Workspace
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 08:49 AM
Hi Ram,
I doubt this can be achieved
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
07-30-2020 10:20 AM
Hi
I changed the script like below. I'm getting values in the variable but the values are not getting set to the form.
Now, I checked the Client script written for UI16 which is also stopped working.. V strange behavior as it worked yesterday and not now.
var url = top.location.href;
alert(url);
var ritmTab = "sc_req_item";
if (url.includes(RITMstring)) {
alert("sc_req_item is in URL");
var indexOfRITM = url.indexOf(ritmTab);
var indexOfSysIDstart = indexOfRITM + ritmTab.length + 1; // index of sc_req_item substring start + lenght of sc_req_item substring + 1 (lenght of "/") that means this is index of first char after "...sc_req_item/"
var sysIDlenght = 32; // sysID is always 32 chars long
var ritmID = url.substring(indexOfSysIDstart, indexOfSysIDstart + sysIDlenght);
g_form.setValue("source_record", ritmID);
g_form.setValue("source_table", ritmTab);
g_form.setValue("u_escalation_type", "4");
alert(ritmID);
} else {
alert("sc_req_item is NOT in URL");
}
Best Regards,
Ram