Fetching values from URL - Agent Workspace

ramwons
Kilo Expert

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: 

https://xyzdev.service-now.com/now/workspace/agent/record/sc_req_item/7f93e37b1ba33f0020c8fddacd4bcb...

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();

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ram,

there might be some restrictions in client script in terms of how values from URL can be fetched

please refer below links for help

https://community.servicenow.com/community?id=community_question&sys_id=a2fd8bbf1b058450d01143f6fe4b...

https://community.servicenow.com/community?id=community_question&sys_id=42eafd121b0dc4d4d01143f6fe4b...

https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/GlideAgentWorkspaceAPI#gaw-op...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

I referred the given links and used the below code.

var url = top.location.href;
alert(url);

 

I'm getting the URL. Thanks. But can you help me in getting the "sc_req_item" & sysID from the printed URL..

 

https://xyzdev.service-now.com/now/workspace/agent/record/sc_req_item/7f93e37b1ba33f0020c8fddacd4bcb...

 

Best Regards,

Ram

Hi Ram,

So you want source_record

Set UI Type as ALL

Can you try this

var url = top.location.href;

var comp1 = new URLSearchParams(url).get("source_record");

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, It's giving me NULL.

var url = top.location.href;
alert(url);

var comp1 = new URLSearchParams(url).get("source_record");
alert(comp1);

 

Best Regards,

Ram