Is there a way to read URL parameters in Record Producer script?

dhananjay_m
Kilo Contributor

I have a Record Producer which I am calling from a related list new button UI Action. This UI Action redirects with some parameters to the Record producer form. Now I want to use the parameters when I am submit the form and I am looking for a way to access the URL parameters within a Record Producer's script. I tried various things like window.location.url, g_form.getParameter(), etc neiter window object is defined and nor g_form works.

Appreciate your help.

Thanks,
Dhananjay

8 REPLIES 8

Jim Coyne
Kilo Patron

Check out the following post: Passing parameters on different forms


dhananjay_m
Kilo Contributor

@Jim That's precisely what I had tried. I can access the URL parameter within my Record Producer onLoad script. I even went ahead and created a Catalog variable to store this value. Now when I want to access this variable in Record producers script block using something like
gs.log('custom_param' + producer.custom_param);

But this always returns me undefined. Any idea why ?

-Dhananjay


Jim Coyne
Kilo Patron

Check out the "Parameter Test" record producer I just setup on demo10.

I have created a "Create Incident" UI Action on the cmdb_ci table, so if you go to any CI, click on the Create Incident button you will be redirected to the record producer which reads the parameter from the URL and populates the CI variable. It will then set the cmdb_ci field on the incident table by reading the producer.ci variable. Of course it would be simpler to just name the "ci" variable to "cmdb_ci" and the producer will assign it automatically for you, but I wanted to show you it can read the producer.ci variable.

I even added


gs.log('sysparm_ci = ' + producer.ci);
to the script and it is showing the sys_id in the logs.


Sorry I may be late in accessing this, but does this still exists on demo instance? I had also attempted something similar and I was able to read the parameter of query string from URL and set it a variable on the form. But can a URL parameter be read directly in the script block of Record Producer instead of storing it in variable & then retrieving it again?