EncodeURIComponent() issue in URL from New Call to Request

Suzanne_Ryan
Giga Expert

We are moving New Calls to Requests and need to include description and short description in the URL that opens up a Request Item.   Reserved and unsafe characters are stopping the URL from processing properly. What is the correct way to script the encoding of the URL?

Here is what I've tried.     This is from the business rule called "CallTypeChanged to Request"

1.   When I try to encode the entire URL I get a message telling me it can't find the page.

var reqFor = current.caller;

var location = current.caller.location;

var reqItem = current.request_item;

var desc = current.description;

var sdesc = current.short_description;

var comments = "NEW_CALL_REF:"+current.sys_id+" "+current.description;

var url = encodeURIComponent('com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem + '&sysparm_user=' + reqFor + '&sysparm_location=' + location + '&sysparm_comments=' + comments + '&sysparm_description=' + desc + '&sysparm_short_description=' + sdesc);

2.   When I try to encode portions of the URL, the rest of the URL doesn't transfer properly from the New Call to the Request.     The encoded portions do transfer properly.   But I need location and requester, and they come over as "undefined".     And when I encode them, they still come over to the request item as undefined.

var reqFor = current.caller;

var location = current.caller.location;

var reqItem = current.request_item;

var desc = current.description;

var sdesc = current.short_description;

var comments = "NEW_CALL_REF:"+current.sys_id+" "+current.description;

var url = 'com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem + '&sysparm_user=' + reqFor + '&sysparm_location=' + location + '&sysparm_comments=' + comments + &sysparm_description=' + encodeURIComponent(desc) + '&sysparm_short_description=' + encodeURIComponent(sdesc);

3. When I try to encode the variable data and then place it in the URL, the data doesn't transfer.

var reqFor = current.caller;

var location = current.caller.location;

var reqItem = current.request_item;

var desc = encodeURIComponent(current.description);

var sdesc = encodeURIComponent(current.short_description);

var comments = "NEW_CALL_REF:"+current.sys_id+" "+current.description;

var url ='com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=' + reqItem + '&sysparm_user=' + reqFor + '&sysparm_location=' + location + '&sysparm_comments=' + comments + '&sysparm_description=' + desc + '&sysparm_short_description=' + sdesc;

Any help here would be greatly appreciated.  

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

This works and the parameter get's passed



gs.setRedirect("com.glideapp.servicecatalog_cat_item_view.do?&sysparm_id=c9e2388a0fe23100781ccf8ce1050e96&sysparm_call_id=" + current.sys_id);



Now read the data from the URL using


decodeURI(document.URL.parseQuery()['sysparm_call_id'])



Use the sys id, query the table and get the call details needed.


View solution in original post

9 REPLIES 9

Kalaiarasan Pus
Giga Sage

I have a question before answering on the encoding part. Have you considered the size of description field? If I remember, IE can handle only 1024 characters URL. We had used the exact sample approach and burnt our hands.



I would suggest you to just pass the call ticket reference in the URL. In the catalog, read the reference, use a glideajax to query and get the field values of the call ticket.


Hi Kalai,



I haven't considered that.   I've never done a glideajax query, and would need assistance setting it up.   Would you help me do that?



I would also like to know the answer to the encoding issue since I am just completely frustrated by it.



Thanks!



Suzanne


Refer this link for glideajax


Just try passing the sys id of call ticket in the URL. Grab it in a onload script and do a query of the call table using the sys id in the script include and return needed values from it. Use glideajax to call the script include from client script.

I will get back to you on the encoding part tomorrow.

Kalaiarasan Pus
Giga Sage

This works and the parameter get's passed



gs.setRedirect("com.glideapp.servicecatalog_cat_item_view.do?&sysparm_id=c9e2388a0fe23100781ccf8ce1050e96&sysparm_call_id=" + current.sys_id);



Now read the data from the URL using


decodeURI(document.URL.parseQuery()['sysparm_call_id'])



Use the sys id, query the table and get the call details needed.