Agent Workspace: How to Pass and Get parameters via URL in Agent Workspace?

ashwanikumar
Tera Expert

Dear All,

We have an existing setup in ServiceNow to auto populate Requested for & Requested By variables in catalog items when created from an incident.

When Agent click on 'Create Request' in an incident form, we pass the following parameter:

var url = "catalog_home.do?sysparm_view=catalog_default&sysparm_processing_hint=setfield:request.parent=";
url += current.sys_id;

and redirect to above URL.

We have an onload catalog script to get the URL Parameter:

function onLoad() {
    var gURL = new GlideURL();
    gURL.setFromCurrent();
    var value1 = gURL.getParam("sysparm_processing_hint");
    var str = value1.replace("setfield:request.parent%3d", "");
    var ga1 = new GlideAjax('get_group');
    ga1.addParam('sysparm_name', 'Sendincsysid');
    ga1.addParam('sysparm_incSysID', str);
    ga1.getXML(responseSetVariables);

    function responseSetVariables(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer != "" || answer != null) {
            var myarray = answer.split(',');
            for (var i = 0; i < myarray.length; i++) {
                g_form.setValue('requested_by', myarray[0]);
                g_form.setValue('u_on_behalf_of', myarray[1]);
            }
        }
    }
}

 

Same code is not working on Agent Workspace.

We have a new UI Action 'Create Request' on Incident table for agent workspace (Workspace Form Menu is true) available on New York version.

I am  unable to pass and get the parameter on script using var gURL = new GlideURL(); system stops script execution. (Also agent workspace URL is embaded and parameter automatically add ASCII code on URL.)

 

Thanks in advance!

Kumar

13 REPLIES 13

Hello Chay,

You're right, i have to clear the session. I"ll update my answer. I've added the clear command in the onLoad client script so it is cleared directly after it has been set.

This will help a little bit but as you mentioned this still can cause issues when a Agent abandons the request.

Thank you!

Stefan,

Thank you this is really helpful.

How does solution work when there is no customer service management?

Hi Muralikaza,

I'm guessing you are using another workspace as the Agent Workspace is only available when you have a CSM in place. I think you can still use my method as an example and adjust the fields to get and set the information you need elsewhere in your Workspace of choice.

I hope this works out for you, good luck!

Regards,

Stefan

Hi Stefan/all,
I adapted this for interactions but on Step 3 I had to use 

if (requested_for != 'undefined') 

instead of 

if (requested_for != '') 

 

otherwise the default value javascript:gs.getUserID(); on the 'requested for' variable would not be used