- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎10-18-2020 10:27 PM
I thought I'd share my solution to passing variables from interaction records to record producers in agent workspace as I struggled to find any solutions that worked for my requirements.
I have been tasked with configuring agent workspace to pass variables to the incident and a general request (record producer) form from interaction records. The idea is that Service Desk staff will use the interaction record for first contact with a customer and then spawn an incident or general request based on the content of their interaction.
To pass variables to the incident form was easy enough and just required a couple more lines to the existing UI Action. The general request was not so easy as the out of the box request UI Action couldn't pass variables directly to the record producer. I'm pretty sure I looked at every article and how-to guide out there but none of the options presented were working for me.
In the end, I used parts of this ServiceNow Guru article to assist in sending/receiving parameters to/from the URL and then created custom regex filters to pull out the 3 variables I required. The URL in agent workspace is not formatted like non-agent workspace URL's in ServiceNow so the standard ways of obtaining the parameters did not work. Here's the code for how I got it all working:
UI Action: Workspace Client Script
function onClick() {
var result = g_form.submit('sysverb_ws_save');
if (!result) {
return;
}
result.then(function() {
var params = {};
params.sysparm_parent_table = "interaction";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
params.sysparm_shortDescription = g_form.getValue('short_description');
params.sysparm_caller = g_form.getValue('opened_for');
params.sysparm_type = g_form.getValue('type');
g_service_catalog.openCatalogItem('sc_cat_item', '471cd65f1bcf98100f7c982d0d4bcbe2', params); //Gets the record producer matching the sys_id
});
}
Catalogue Client Script: OnLoad
function onLoad() {
//Use the 'getParameterValue' function below to get the parameter values from the URL
var url = top.document.URL;
var shortDescPattern = new RegExp('(?<=description\/)(.*)(?=\/sysparm-caller)');
var shortDesc = shortDescPattern.exec(url);
if (shortDesc) {
g_form.setValue('short_description', shortDesc[0]);
}
var callerPattern = new RegExp('(?<=sysparm-caller\/)(.*)(?=\/sysparm)');
var caller = callerPattern.exec(url);
if (caller) {
g_form.setValue('requested_for', caller[0]);
}
var typePattern = new RegExp('(?<=sysparm-type\/)(.*)');
var type = typePattern.exec(url);
if (type) {
g_form.setValue('contact_type', type[0]);
}
}
This does require that the URL is formed in a specific way, but as long as you add additional variables to the end of the workspace client script, it shouldn't break any of the previous ones.
I hope this helps someone else out there 🙂
Cheers,
Brad
- 3,664 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Brad.
1 question... How did you put in the relationship between the Interaction Record and the record from the record producer.
We want to use a UI action to say: create ticket rather then create INC and take the agent to the Service Catalog.
When they select catalog items, we managed to relate the Interaction with the RITM, but we fail to do same on INC records as they come from record producers...
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Can you share your getParameterValue script?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Brad,
Good Day!!
I would like to pass assignment group as well. Could you please provide code for that?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Brad,
I have similar type of requirement:-
In Agent Workspace, we have got 2 fields as short description & description. Whenever Service Desk's user click on Create User, it's redirected to a specific catalog item and we would like to populate these 2 fields Short Description & Description variables in the catalog item from Interaction automatically.
Could any one of you please let me know whenther you came across such/ similar requirement and help/guide me to achieve the same please?
Quick reply much appreciated!!!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am trying to implement this in our Service Operations Workspace.
The getParameterValue() is not returning any sysparms I needed. When I debug, client script returns the url with all the params. But, when I do getParameterValue(), I am not getting the sysparms value.
Do you know why?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How can we do this similar requirement with out DOM manipulation?