Want to get the URL of the current page in the portal

ms_akila
Mega Expert

I wanted to get the current url of thecatalog portal and to use the url in reference qualifier to get the sys_id of case

Sample Url: instance.service-now.com/portal_name&sys_id= &case_id

Now in reference qualifier of a catalog item needs to get the url and filters the value based on case _id.

 

Anyone please share your ideas?

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Akila,

you can directly get the url in the script include function and within that use this script to get the url parameter value

var url = gs.action.getGlideURI().toString();

to get value of case_id use this

var caseId = gs.action.getGlideURI().getMap().get('case_id');

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

ms_akila
Mega Expert

Hi Ankur,

 

I have tried the above script but it was returning "null' value;

 

below is my script;

javascript:var catsysID = current.cat_item;
var cusAccount= gs.action.getGlideURI().getMap().get('case_id');
gs.log("getParam URL"+cusAccount);

Hi Akila,

Can you try to print the url first to check whether that url parameter is present or not?

Regards

Ankur

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

Kajal Goti
Mega Guru

Hi,

You can get portal current page url like this.

var currenturl=this.location.href;

Refer below link.it will help you.

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

 

Mark as correct/helpful,If you find any help worthy.