How to get URL params in script include

anjaneyulumuvva
Kilo Expert

Hello,

i need to get URL parameter in script include.this script include will trigger by variables reference qualifier.

i didn't find the solution to get params in script include.Please help me.

14 REPLIES 14

Not applicable

This should be quite straightforward. Try setting your reference qualifier to something like this:

javascript:new MyScriptInclude().methodName(gs.action.getGlideURI().toString());

Your Script Include will look something like this:

var MyScriptInclude = Class.create();
MyScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {

methodName: function(parm) {
gs.addInfoMessage(parm); // Display the URL parameter to check it works

// Insert logic here to process 'parm' and create a dynamic query

return "active=true"; // Return an encoded query string
},

type: 'MyScriptInclude'
});

Let me know if this helps!

thank u for ur reply,

i have tried that given code. by this code url is coming like this

angular.do?sysparm_type=sp_ref_list_data

but my actual service portal url is 

https://dev16236.service-now.com/sp?id=sc_cat_item&sys_id=0061c4274f105300b4787bb28110c736

ManideepN
Tera Contributor

Hi,

I am also working on the same issue, can you help me out on this if you find any solution.

 

Thanks,

Manideep Nadimpelli.

Mahesh Kumar7
Mega Expert

In Client side use : "window.location.href" or "document.URL"

 

In Server side use:  gs.getProperty("glide.servlet.uri")+gs.action.getGlideURI()

PraveenGoud1
Giga Contributor

Hi,

This is can be done by creating a variable on the catalog/record producer / table and hide it on form.
Create a onload client script and pass the url to the created variable. (top.location.href)

var url = top.location.href;

g_form.setValue('variablename', url);
Then pass the variable value to the reference Qualifier like new ScriptInclude().MethodName(current.variablename)