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

Hi,


Suggested solution is not working under Fuji version.



Thanks,


Sanjeev Kumar


johnlampson
Giga Contributor

Hi Sanjeev!



I had a situation where I needed to construct an e-mail to a client that would take them to an order guide and populate a field based on a value in the URL they clicked.



In this case, I configured my URL so that it ended with &pid=0a9sdf809sd09sf098sd0f8 (the sys_id of the user account).



Obviously, the majority of the URL took them to the instance and then to the form, but once the form loaded, I created a script against it, as follows:



function onLoad() {



  window.setTimeout(patience,500); //We don't want this to run immediately because there might be other scripts that set or clear a value, so we'll wait half a second



  function patience(){


  var url = window.parent.location.href; //Let's check the URL


  if (url.indexOf("&pid=")>=1) //This looks for a value of "&pid=" in the URL string. If we get one, the below code runs


  {


  var match = url.match(/&pid=([a-zA-Z0-9]+)/); //RegEx is magical


  var pid = match[1]; //Grab the value that comes after "&pid=". That will be the user's sys_id.


  g_form.setValue('requested_for', pid); //Set the requested_for field with the sys_id


  }


  return;//If there isn't a "&pid=" value, we do nothing.


  }


}



Let me know if this helps!



John


Hi John,



It is not working. I am using Fuji version.



Thanks,


Sanjeev Kumar