attaching documents to newly created case using VA

Suzanne H
Giga Guru

Documents attached during case creation using Virtual Agent is not working. Users on Employee Center open Virtual Agent to open an HR case. The virtual agent asks if they have documentation and then asks how many. The user selects the number and then attaches documents one by one. When complete, the HR Case number is provided to the user. The user clicks on it and sees the detail but no attachments. HR users also do not see attachments on the newly created case. I have checked the Action expression script on the Create HR Case node and it is correct. Does anyone know why the documents aren't not attached to the case and where they end up?

Action expression

(function execute() {
    var hrServiceId = vaInputs.hr_service.getValue();
    var caseTable = vaInputs.case_table.getValue();
    var questions = vaInputs.case_questions;
    if (!gs.nil(hrServiceId) && !gs.nil(caseTable) && !gs.nil(questions)) {
        questions = JSON.parse(vaInputs.case_questions);

      var additional_comments = {
            question: "Any additional information you would like to add to the case?.",
            name: "additional_comments",
            answer: vaInputs.additional_comments,
            raw: vaInputs.additional_comments,
            answerDisplayValue: vaInputs.additional_comments
        }
     //  var userID = gs.getUserID();
        questions.push(additional_comments);
        

        var caseDetails = new sn_hr_va.hr_ChatbotUtils().createCaseWithHRService(hrServiceId, caseTable, questions);
        vaVars.case_sysid = caseDetails.sysid;
        if (vaVars.case_sysid) {
            vaVars.is_case_created = true;
            vaSystem.attachRecordToConversation(caseTable, caseDetails.sysid);
        }

        var gr = new GlideRecord('sn_hr_core_case');
        if (gr.get(vaVars.case_sysid)) {
            gr.work_notes = vaSystem.getTranscript();
            gr.u_effective_end_date = vaInputs.effective_end_date;
            gr.u_effective_start_date = vaInputs.effective_start_date;
            gr.u_hr_service_subclass = vaInputs.hr_subclass.getValue();
            gr.priority = vaInputs.priority;
            gr.short_description  = vaInputs.short_description;
            gr.subject_person = vaInputs.subject_person;
            gr.u_subject_person_not_found = vaInputs.subject_person_not_found;
            gr.u_name = vaInputs.not_found_name;
            gr.u_email_address = vaInputs.email;
            gr.u_candidate_number = vaInputs.candidate_number;
            gr.u_destination_country = vaInputs.destination_country;
            gr.u_destination_city = vaInputs.destination_city;
            gr.u_initiating_source = vaInputs.request_source;
            gr.u_source_topic = vaInputs.source_topic;
            gr.update();
        }
    }
})()

 

3 REPLIES 3

Medi C
Giga Sage

Hello @Suzanne H,

 

Could you please open interaction table (interaction.LIST) and check if the attachments are linked on your interaction record?

 

If the attachments are there, you may try to add the following to your script: (after gr.update())

 

GlideSysAttachment.copy('interaction', vaVars._interaction_record_sysid, 'sn_hr_core_case', gr.sys_id);

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

Suzanne H
Giga Guru

@Medi C 

Thanks for your help! I don't know how I missed this message from 3 weeks ago. The attachments are not on the interaction table, they are also not on the sys_attachment table.

Suzanne H
Giga Guru

progress, I added a script action (below) to the topic right after case creation and now the attachment is on the sys_attachment table. 

(function execute() {

    vaSystem.attachToRecord(vaInputs.file_picker.getValue(), 'sn_hr_core_case', vaInputs.create_sn_hr_core_case);

})()

 

I've tested creating two hr cases and see the attachments on two different tables, the first one is on sys_cs_conversation_task and the second one is on sys_cs_conversation. I'm not sure what to change in the GlideSysAttachment.copy script

This is what I tried

GlideSysAttachment.copy('sys_cs_conversation_task', vaVars._attachment_record_sysid, 'sn_hr_core_case', gr.sys_id);