Passing variables from interaction record ti catalog item in Agent Workspace

Forrest Falk
Kilo Expert

We are starting to implement the ITSM Agent Workspace and would like to pass the the opened for variable on the interaction record to a variable in the catalog item form. How can you pass a variable from the interaction record in the Agent Workspace to the catalog item when an agent presses the create request button on the interaction record? 

Thank you in advance for any tips or tricks!

Example Steps:

1. First an interaction record is created for a user and then the "Create Incident" button is pressed

find_real_file.png

2. The service catalog it opened from the "Create Request" button. We then select a catalog item (Smart Hands in this case).

find_real_file.png

3. Finally the catalog item (Smart hands) is opened and currently displays the logged in user, but we would like to pass the variable over from the interaction record.

find_real_file.png

1 ACCEPTED SOLUTION

Forrest Falk
Kilo Expert

We figured it out. Below is an example script on how to get a user from an interaction in agent workspace and apply it to a requested for field on a catalog item.

 

find_real_file.png

View solution in original post

8 REPLIES 8

What type of script was this?  Was it on the UI Action or something else?

Hello,

I'm trying to accomplish something similar, passing a variable from a case to a catalog item variable.
But it is not working.
I created a scrip under Systems Definitions, Client Scripts but is not doing anything:

function onLoad() {
   //Type appropriate comment here, and begin script below
   var reqLocation = localstorate.getItem("u_site_acronym");
   if(reqLocation)
    g_form.setValue('Location', reqLocation);
    localStorage.clear();
}

Any advice?

Thanks

Forrest Falk
Kilo Expert

If you want to know more about local storage in the browser, you can view the API here:

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage


Basically you will want to do the following steps:

  1.  Create a client script that loads the local storage when your form field is changed:
    //Get the value of the name field
    var name = g_form.getValue('name');
    //Set the name field to a "name" variable on the browser's storage
    localStorage.setItem('name', name);​
  2. On the form you want to set a field you will want to have an onLoad client script to grab the value and then clear the value after you have used it:
    //Get name value from local storage
    var name = localStorage.getItem('name');
    //Set the name field from local storage
    g_form.setValue('name',name);
    //Clear the local storage
    localStorage.removeItem('name');
    ​

 

Also if you need to clear all of the storage you have been using you can use the clear() function:

// Clear all items
localStorage.clear();

 

Let me know if you have any other questions!

Best,

Forrest

jsanjuan
ServiceNow Employee
ServiceNow Employee

If you are only interested in passing the "created for" from an interaction to the requested item's "requested for", be sure that the user is matched by a role on glide.sc.req_for.roles property, or glide.sc.req_for.roles.default  = allow rather than deny.

 

You can refer to https://docs.servicenow.com/bundle/utah-servicenow-platform/page/product/service-catalog-management/...