Create HR case from VA
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
7 hours ago
Hello,
I need a help for creating a HR case from VA when live agent is not available or when VA is not provided the enough information.
So for this, I have created a custom topic where I have included the topic block and added OOB Create HR case(LLM) topic block, which has a input mappings , HR service - General, table - sn_hr_core_case and in case question written a script -
(function execute() {
// Grab the text the user just typed into your new node
var userText = vaInputs.please_describe_your_issue.getValue();
// Format the OOB array targeting the description column
var questionArr = [{
"question": "Please describe your issue?",
"name": "description",
"mappingField": "description",
"answer": userText,
"raw": userText,
"answerDisplayValue": userText
}];
// Convert it to a clean string format for the backend script
return JSON.stringify(questionArr);
})()
(I am adding one extra node in the custom topic flow for the question to get the user input and to update that in a description field, but basically based on user chat history it must automatically update the description but its not happening either.)
(I am adding one extra node in the custom topic flow for the question to get the user input and to update that in a description field, but basically based on user chat history it must automatically update the description but its not happening either.)
From the main topic the case is creating successfully but it is not updating the description field , Subject person, contacting person fields.
so I have modified the topic block by duplicating the oob one like shown below,
so I have modified the topic block by duplicating the oob one like shown below,
(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 vaUtils = new sn_hr_gen_ai.HRSDVAUtils();
//if (!gs.nil(vaInputs.additional_comments)) {
// questions.push(vaUtils.prepareQuestion(gs.getMessage("Please provide additional comments for your case."), "additional_comments", vaInputs.additional_comments, vaInputs.additional_comments));
//}
// Create case
var caseDetails = vaUtils.createCaseWithHRService(hrServiceId, caseTable, questions);
var userDescription = '';
for (var i = 0; i < questions.length; i++) {
if (questions[i].mappingField && questions[i].mappingField == 'description') {
userDescription = questions[i].answer;
break;
}
}
if (caseDetails.sysid && userDescription) {
var hrCase = new GlideRecord(caseTable);
if (hrCase.get(caseDetails.sysid)) {
hrCase.setValue('description', userDescription);
if (hrCase.isValidField('rich_description')) {
hrCase.rich_description = userDescription;
}
hrCase.update();
var verify = new GlideRecord(caseTable);
if (verify.get(caseDetails.sysid)) {
if (verify.isValidField('rich_description')) {
gs.info('[HR_DEBUG] Verify Rich Description = [' + verify.getValue('rich_description') + ']');
}
}
}
}
vaVars.case_sysid = caseDetails.sysid;
if (vaVars.case_sysid) {
vaVars.is_case_created = true;
vaSystem.attachRecordToConversation(caseTable, caseDetails.sysid);
// Add transcript to the work notes
vaUtils.addWorkNotes(caseTable, vaVars.case_sysid, vaSystem.getTranscript());
}
}
})()
From this script, now rich_description field is getting updated but still not the description field.
one more issue is, as per our requirement we need to show the preview of the HR case before creating the case, How to achieve this ?
From this script, now rich_description field is getting updated but still not the description field.
one more issue is, as per our requirement we need to show the preview of the HR case before creating the case, How to achieve this ?
So, main issues are
1. Description field is Empty.
2.Subject and contacting person is empty.
3.Having a preview before creating the case.
4. "Source" in HR case is getting updated as Virtual agent from the oob script include, can we change it via VA main topic or duplicated topic block?
Main topic flow:

Kindly help on resolving on this and Please let me know, if any more details required.
Thanks,
0 REPLIES 0