Transfer Values from interaction to a specific catalog item in agent workspace

Community Alums
Not applicable

Hello,

I am looking for some help with the ITSM Agent Workspace. I have a requirement where I need to open a request from an interaction for the analysts to add more information into. We have created a specific request item that needs to be used for this. Currently, I am able to open the form in the workspace from the interaction, using the create request button for this, but not able to copy the values for the short description and user name from the interaction into the form. 

I have tried various community suggestions but nothing worked for me. The closest I got to getting it work is via passing the values as parameters on the url and then extracting it from the URL using a catalog client script. But what I found when I did this is that it copies the values into the subsequent requests opened via interaction and does not get the new values from the current interaction. 

I would appreciate any suggestions if anyone has got this working. I will post what I have below.

Workspace Client Script for Create request UI action:

function onClick(g_form) {
g_form.setValue('state', 'closed_complete');
//g_form.save();
var result = g_form.submit('sysverb_ws_save');
if (!result) { // failed form submission
return;

}
result.then(function() {
var openedFor = g_form.getValue("opened_for");
var shortDescription = g_form.getValue("short_description");
var params = {};
params.sysparm_parent_table = "interaction";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
params.sysparm_username = openedFor;
params.sysparm_shortdesc = shortDescription;
g_service_catalog.openCatalogItem('sc_cat_item', '1afd64881b23c0106956535c2e4bcba6', params);
});
}

 

Catalog Client Script created(username did not work. Only Short description did):

 

function onLoad() {
 
    var url = top.document.URL;
    // Define a regex pattern to capture the SYSID from the URL
    var regex = /sysparm-username\/([a-fA-F0-9]{32})/;
    var regex2 = /sysparm-shortdesc\/(.*)/;
 
    // Use the regex pattern to extract the SYSID from the URL
    var match = url.match(regex);
    var match2 = url.match(regex2);
//alert(match2);
 
    if (match) {
        var sysId = match[1]; // Extracted SYSID
        var userName = sysId.toString();
       g_form.setValue('u_short_description', userName);
 
    } else {
        alert("SYSID not found in the URL.");
    }
   if (match2) {
        var shortDesc = match2[1]; // Extracted SYSID
        g_form.setValue('u_short_description', shortDesc);
    } else {
        alert("Short Description not found in the URL.");
    }
}
PradeepGeorge_0-1699000297589.png

 

1 ACCEPTED SOLUTION

Abbas_5
Tera Sage
Tera Sage

Hello @Community Alums,
Please refer to the below link:
https://www.servicenow.com/community/csm-forum/passing-variables-from-interaction-record-ti-catalog-item-in/m-p/402456

 

If it is helpful, mark it as a thumbs-up and accept the correction solution.
Thanks & Regards,
Abbas Shaik

View solution in original post

2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

Hello @Community Alums,
Please refer to the below link:
https://www.servicenow.com/community/csm-forum/passing-variables-from-interaction-record-ti-catalog-item-in/m-p/402456

 

If it is helpful, mark it as a thumbs-up and accept the correction solution.
Thanks & Regards,
Abbas Shaik

Community Alums
Not applicable

Thank you Abbas. That's amazing. Works really well.