How to get entire URL in Client Script OR sysparm

Sanjeev Kumar1
Kilo Sage

Hi All,

I have created a custom table for new record system give us a URL Like.

x_abc_manage_app_app_req.do?sysparm_stack=x_ncrrp_manage_app_app_request_list.do&sys_id=-1

I want to pass one more parameter like

x_abc_manage_app_app_req.do?sysparm_stack=x_ncrrp_manage_app_app_request_list.do&sys_id=-1&sysparm_ab_id=2345t56y7u7

I what to get this parameter in onload client Script.

Please let me know how we get this value in Client Script.

Thanks,

Sanjeev Kumar

1 ACCEPTED SOLUTION

Sanjeev Kumar1
Kilo Sage

Hi All,


If you change application Scope global



window.parent.location.href



Code will work. I thing there are some BUG in Fuji.


Now when I change scope global it is working.



Thanks,


Sanjeev Kumar


View solution in original post

14 REPLIES 14

Can you post your version of the code as well as an example of the URL? Also, is this being presented in ESS or in the standard UI?


I am using in standard UI.



x_ncrrp_manage_app_app_request.do?sysparm_stack=x_ncrrp_manage_app_app_request_list.do&sys_id=-1&appsys_id=aeae2c27d5a0c64044e6692b4699602d


Instead of var url = window.parent.location.href, try



var url = window.location.href.



Also, is this on a catalog item? Mine was on an ESS catalog item.


This is not really a ServiceNow code that depends on ServiceNow release.. It works perfectly fine.. Make sure your script is getting called.



function getParmVal(name){


      var url = document.URL.parseQuery();


      if(url[name]){


              return decodeURI(url[name]);


      }


      else{


              return;


      }


}




Manjul Katare
ServiceNow Employee
ServiceNow Employee

Hi Sanjeev,



Try this out, I have used this script on quite a few times on different releases to pass some value through the URL parameter



Assume your URL is something like this :   https://<instance-name>/your_custom_table_list.do&req_type=SAP



You script should be as written below:



function onLoad() {


  var url = window.location.toString();


  var parms = url.toQueryParams();


  if (parms["req_type"] == "SAP") {


            // Do something here....................


  }


}



Hope this helps!


-Manjul