Passing a value via URL into a record producer

Jeff Krueger1
Tera Expert

I am trying to populate the description variable on a record collector form from an external URL.   I am able to do so on a new Call form with the following URL:

https://<instancename>.service-now.com/nav_to.do?uri=new_call.do?sys_id=-1%26sysparm_query=description=this+is+the+description

which results in:

find_real_file.png

however, I'm unable to successfully pass it to a record collector for the New_Call table to the description variable.   What am I missing?   Can this be accomplished the same way with a sysparm_query?   Any help would be much appreciated, thanks!

1 ACCEPTED SOLUTION

Or try below keeping the + sign


g_form.setValue('description',parm[1].toString().replace(new RegExp("\\+","g"),' '));



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

14 REPLIES 14

SanjivMeher
Kilo Patron
Kilo Patron

You said you are able to do it by the URL. Then what is the issue?



Please mark this response as correct or helpful if it assisted you with your question.

The problem is I am trying to get the same result into a record producer and not a new Call record:



find_real_file.png



Adding %26sysparm_query=description=this+is+the+description to the URL for it does not populate the field shown above.   The value for the variable is "description", however, I'm not certain how to refer to it being that it is a variable in a record producer rather than a field on a table.


You need an onLoad client script on your record producer to interpret it



var link = parent.window.location.href;



var hash = link.split('&');


var parm = '';


for (var i=0;i<hash.length;i++)


{


if (hash[i].indexOf('description')>-1)


{


parm = hash[i].split('=');


g_form.setValue('description',parm[1].toString());


}


}



And your link should be like this



/com.glideapp.servicecatalog_cat_item_view.do?sysparm_initial=true&sysparm_id=your record produver sysid&description=this+is+the+description



Please mark this response as correct or helpful if it assisted you with your question.

Thank you very much Sanjjiv, this does pass the description into the variable.   The only thing now is spaces are not being put in for + or %20, it's putting in literally what is after the "description=" in the URL (this+is+the+description).   Do you know how to modify the onLoad client script to properly put in spaces and/or linefeeds ()?