We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Create HR case using Request catalog item topic block

poornimanar
Tera Contributor

Hello,

 

I am facing issue with the OOB Request Catalog item (LLM) Topic Block,  I have a requirement where I need to create a case from VA with one particular record producer.

In order to achieve this , I have created a custom topic and included a OOB topic block "Request Catalog Item(LLM) but with this topic block, when I click on the submit for the first time, it fails to create a case and again it gives the options to submit, add attachments, Make changes when I again click on Submit it successfully creates the case.

 

This is the script in oob topic block for creating the HR case,

 

(function execute() {
    var itemJson = JSON.parse(vaVars.itemJSON);
    var variablesObj = {};
    var attachmentIds = [];
    for (i = 0; i < itemJson.variables.length; i++) {
        variablesObj[itemJson.variables[i].name] = itemJson.variables[i].value;
        if (itemJson.variables[i].type === 33)
            attachmentIds.push(itemJson.variables[i].value);
    }
    vaVars.variables = JSON.stringify(variablesObj);
    var reqObject = {
        "sysparm_id": itemJson.sys_id,
        "sysparm_action": 'execute_producer',
        "variables": variablesObj,
        "engagement_channel": 'va',
        "contact_type": 'virtual_agent'
    }
    vaVars.status = "error";
    var response = new sn_sc.CatItem(itemJson.sys_id).submitProducer(reqObject);
    if (response) {
        vaVars.status = "success";
        vaVars.record_id = response.sys_id;
        vaVars.record_table = response.table;
        // add attachment to record
        var mediaLinksFormAttachment = vaVars.media_links_form_attachment.split(',');
        for (var i in mediaLinksFormAttachment)
            vaSystem.attachToRecord(mediaLinksFormAttachment[i], response.table, response.sys_id);

        // move attachment variable to record
        // ONLY try to move attachments if we have valid files to move
        if (attachmentIds && attachmentIds.length > 0) {
        var gr = new GlideRecord('sys_attachment');
        gr.addQuery('sys_id', 'IN', attachmentIds);
        gr.query();
        while (gr.next()) {
            gr.setValue('table_name', 'ZZ_YY' + response.table);
            gr.setValue('table_sys_id', response.sys_id);
            gr.update();
        }
     }
    }
})()

Can someone please check and help me on this? 
There is also one more issue, with "contact_type": 'virtual_agent' , after creating the case the source field still updates with self service , how to update it with virtual agent.
0 REPLIES 0