Both decodeURIComponent() and decodeURI() not work on scoped application

Antonio42
Kilo Guru

Team, I am trying to decode an URL, but I am getting undefined value. Could you guys know how to resolve it?
Find below my code:

function getParameterValue(pName){

    var glideURL = new GlideURL();
    glideURL.setFromCurrent();
    var url = glideURL.getParam(pName);

    return decodeURI(url[pName]);
    //return decodeURIComponent(url[pName]);
}

 

15 REPLIES 15

Hi Antonio,

From where the record is opened/navigated from?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Using the Call module there is an option to call the catalog item. I am passing the values from call record to catalog item, just it. It works fine on global scope, but not to catalog item on scoped app.

Hi Antonio,

Can you share the script how it is redirected?

Since the url itself doesn't contain those parameters it won't get the value.

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

It is a native business rule named as "CallTypeChanged to Request". I have included several variables to attend my requirement:

var reqFor = current.caller;
var contactType = current.contact_type;
var location = current.caller.location;
var reqItem = current.request_item;
var comments = "NEW_CALL_REF:" + current.sys_id + " " + current.description;
var call = current.sys_id;
var reqForEmail = current.caller.email;
var reqForPhone = current.caller.phone;

var url = "com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=" + reqItem
+ "&sysparm_requested_for=" + GlideStringUtil.urlEncode(reqFor)
+ "&sysparm_location=" + GlideStringUtil.urlEncode(location)
+ "&sysparm_special_instructions=" + GlideStringUtil.urlEncode(comments)
+ "&sysparm_stack=" + current.getLink()
+ "&sysparm_contact_type=" + contactType
+ "&sysparm_call="+call
+ "&sysparm_caller="+reqFor
+ "&sysparm_caller_email="+reqForEmail
+ "&sysparm_caller_phone="+reqForPhone;

action.setRedirectURL(url);
current.isNavigateToCatalog = true;

Hi Antonio,

So from call form you are redirecting to catalog item and sending values via url parameters

In that case you would be writing the onload catalog client script to get the values. are you not getting the correct url? Is it not redirecting to catalog item page?

also action object won't work in business rule to redirect; use this

gs.setRedirect(url);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader