How do you read URL from Catalog Client Script

marclindsay
Tera Guru

I have created a UI Action that runs server side and redirects a user to a Record Producer. The UI Action adds data to the URL (UI Action Redirect : com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=21378b88db9e2300c218d740cf961961&sysparm_comments=testing passing information). Within the Catalog Client Script I am trying to read the URL to get the parameter needed for defaulting some of the fields on the Record Producer screen.

Everything I have read looks like I should be able to do the following to get my data out of the URL. document.URL.parseQuery();  This command is not working. I keep getting the error 'Cannot read property 'URL' of null'.

Stuck as to how I get my information out of the URL

1 ACCEPTED SOLUTION

Ok, Can you try this once.

var gUrl = new GlideURL();
gUrl.setFromCurrent();
var comments = gUrl.getParam("sysparm_comments");
g_form.setValue('description', comments);

 

View solution in original post

16 REPLIES 16

Hello,

I think you are in London. Please set the following flag on your client script from a list view and it will work.

Set Isolate Script to true for your client script, This will allow DOM manipulations.

Build
glide-kingston-10-17-2017__patch9-09-05-2018_09-12-2018_0933

 

 

Don't see that flag

 

Ok, Can you try this once.

var gUrl = new GlideURL();
gUrl.setFromCurrent();
var comments = gUrl.getParam("sysparm_comments");
g_form.setValue('description', comments);

 

That worked but it is showing %20 for spaces. 

"testing%20passing%20information"

Had to add decodeURI to the final code.

g_form.setValue('description', decodeURI(comments));

 

Thanks