Need help in Virtual Agent

Pooja Mallikarj
Kilo Sage

Hi Community,

 

I have a requirement where Virtual agent is going to create a incident with some attachments attached. As I am able to do attachment but in the work notes is showing as updated by caller . I want to change the work notes updated by to "system" instead of caller. How we can change updated by to System for work notes in VA?

 

PoojaMallikarj_1-1690204052184.png

 

 

Thanks in advance.

 

Thanks,

Pooja M

1 ACCEPTED SOLUTION

Hi Riya,

 

Thank you so much for the reply. The above answer gave me some hint to solve my issue .

But the below link helped me to solve my complete issue.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0748347 

 

Thanks,

Pooja M

 

View solution in original post

4 REPLIES 4

Riya Verma
Kilo Sage
Kilo Sage

Hi @Pooja Mallikarj ,

 

 

Hope you are doing great.

 

To achieve the desired behavior of having the Virtual Agent (VA) create an incident with attachments while updating the work notes with "System" instead of "Caller," we can implement the following technical solution:

  1. Create a dedicated script or business rule to handle the incident creation and attachment process from the Virtual Agent.

  2. In the script or business rule, ensure that the work notes field is explicitly set to "System" as the updated by value before updating the work notes content.

 

// Sample code for incident creation and attachment handling in ServiceNow
var caller = gs.getUser(); // Assuming this variable holds the user making the request (Virtual Agent in this case)
var incident = new GlideRecord('incident');
incident.initialize(); // Initialize a new incident record

// Set incident properties here (e.g., short_description, description, etc.)
incident.short_description = 'Incident created via Virtual Agent';
incident.description = 'Incident details provided by Virtual Agent';

// Attachments handling
// Assuming you have the attachment details available, use the following code to attach them to the incident.
// Replace 'attachment_sys_id' with the actual sys_id of the attachment record in ServiceNow.
var attachment_sys_id = 'attachment_sys_id';
var attachment = new GlideSysAttachment();
attachment.write(incident, 'incident', attachment_sys_id);

// Update the work notes field with 'System' as the updated by value.
incident.work_notes = 'Your work notes content here';
incident.work_notes.setJournalEntry(true);
incident.work_notes.updated_by = 'System'; // Setting the 'updated_by' value to 'System'

// Save the incident record
incident.insert();

 

 
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hi Riya,

 

Thank you so much for the reply. The above answer gave me some hint to solve my issue .

But the below link helped me to solve my complete issue.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0748347 

 

Thanks,

Pooja M

 

Thanks @Pooja Mallikarj  for your inputs, and providing link which provides add on details to help you out in scenario. Can you please accept the solution so that it can help other out in building and getting inputs from community. 

 

Thanks in advance. 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Thank you Riya.