Issue with passing virtual agent parameter/variable into script include

DChandlerKy
Tera Guru

We are using VA Chat to facilitate the creation of incident, interaction, and requested item records based on specific customer selections. Incidents and interaction records are created without issue, however, I am having an issue with setting the short description on the requested items. 

In the virtual agent topic, for reference, here is the script action that assists with generating the incident record that works.  

 

(function execute() {
       var full_desc = vaInputs.first_last_name + '\n' + '\n' + vaInputs.description+ '\n' + '\n' + vaVars.epic_parameters ;
       var urgency = ""
   
   // Pass all chat + interaction table data to incident creation
       var caller = vaVars.linkblue;
       var short_desc = vaInputs.description;
       var description = full_desc;
       var patient_info = vaVars.epic_parms_patient;
       var assignment_group = vaInputs.lab_or_it.getValue(); //Epic Security
       var phone_number = vaInputs.contact_number.getValue();
       var category = "Application";
       var subcategory = '';
       var business_application = "";
   
        if (!gs.nil(caller) && !gs.nil(short_desc)) {
           var incDetails = new global.EpicVACreateINCUtil().createIncident(caller, category, subcategory, business_application, short_desc, urgency, description, patient_info, assignment_group, phone_number);
           vaVars.inc_sysid = incDetails.sysid;
           vaVars.inc_num = incDetails.incNum;
        }
    })()


Here is the script action for requests:

 

(function execute() {
       var full_desc = vaInputs.first_last_name + '\n' + '\n' + vaInputs.description+ '\n' + '\n' + vaVars.epic_parameters ;
       var urgency = ""
   
   // Pass all chat + interaction table data to request
       var caller = vaVars.linkblue;
       var r_shortdesc = vaInputs.description;
       var description = full_desc  + '\n' + '\n' + vaVars.epic_parms_patient;
       var patient_info = "";
       var assignment_group = vaInputs.lab_or_it.getValue(); 
       var phone_number = vaInputs.contact_number.getValue();
       var category = "Application";
       var subcategory = '';
       var business_application = "";
      
      gs.log("VA Epic Request Submission short_desc value is " + r_shortdesc);
        
        if (!gs.nil(caller) && !gs.nil(r_shortdesc)) {
           var reqDetails = new global.EpicVACreateRITMUtil().createRequest(caller, category, subcategory, r_shortdesc, urgency, description, assignment_group, phone_number);
           vaVars.inc_sysid = reqDetails.sysid;
           vaVars.inc_num = reqDetails.reqNum;
        }
    })()


The log line in the request script action does correctly capture the short description value. 

The script include that is called in the request script action is below. It is modeled after the script include that is called for incidents (that works.)

 

var EpicVACreateRITMUtil = Class.create();
EpicVACreateRITMUtil.prototype = {
    initialize: function() {},

    createRequest: function(caller, category, r_shortdesc, subcategory, business_application, description, assignment_group, phone_number) {
  
      gs.log('EpicVACreateRITM Script Include value for Short Description is ' + r_shortdesc);
		
        var reqDetails = {};

        var reqGr = new GlideRecord("sc_req_item");
        reqGr.initialize();
        reqGr.setDisplayValue("u_ritm_requested_for", caller);
        reqGr.setDisplayValue("opened_by", caller);
        reqGr.setValue("short_description", r_shortdesc);
        reqGr.setValue("description", description);
        reqGr.setValue("assignment_group",assignment_group); 
        reqGr.setDisplayValue("u_category", category);
        reqGr.setDisplayValue("u_subcategory", subcategory);
		reqGr.setValue("cmdb_ci_business_app", business_application);
        reqGr.setValue("u_contact_number", phone_number);
		reqGr.setValue("u_submit_request_for_review", "no");
        //reqGr.setValue("location", '8e8242e91bb89090b090a79b2d4bcb08'); //Unknown
		reqGr.setValue("contact_type", "Virtual-Agent");
      
        reqDetails.sysid = reqGr.insert();
        reqDetails.reqNum = reqGr.getValue('number');

        return reqDetails; 
    },
	
    type: 'EpicVACreateRITMUtil'
};

 

The log statement shows that the value is not passed from the VA script action into the script include and this is the reason I'm not getting the short description I want. 

DChandlerKy_0-1717511074750.png


Everything else from the VA script action makes it into the requested item record. 


I have compared the two script actions (incident/request) and the script includes to see if I can identify why that value is not being passed and I am coming up empty. 

Any ideas? Thank you!!
Diana

1 ACCEPTED SOLUTION

Muralidharan BS
Mega Sage
Mega Sage

In the VA,

           var reqDetails = new global.EpicVACreateRITMUtil().createRequest(caller, category, subcategory, r_shortdesc, urgency, description, assignment_group, phone_number);

in the SI

    createRequest: function(caller, category, r_shortdesc, subcategory, business_application, description, assignment_group, phone_number) {

 

I think the sub-category and short desc are swapped,

View solution in original post

2 REPLIES 2

Muralidharan BS
Mega Sage
Mega Sage

In the VA,

           var reqDetails = new global.EpicVACreateRITMUtil().createRequest(caller, category, subcategory, r_shortdesc, urgency, description, assignment_group, phone_number);

in the SI

    createRequest: function(caller, category, r_shortdesc, subcategory, business_application, description, assignment_group, phone_number) {

 

I think the sub-category and short desc are swapped,

.... Of course the order matters! 😂 That fixed it. Thank you!