Both decodeURIComponent() and decodeURI() not work on scoped application
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 04:37 AM
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]);
}
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 06:21 AM
Hi Antonio,
From where the record is opened/navigated from?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 06:30 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 07:37 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:06 AM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2020 08:15 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader