How to add multiple attachments from Virtual Agent while creating the Incident?

Vijaya13
Tera Contributor

How to add multiple attachments from Virtual Agent while creating the Incident. 

7 REPLIES 7

Chris D
Mega Sage
Mega Sage

I just have this achieved via a simple loop:

  1. "Would you like to add one or more attachments?"
    • If Yes, File Upload input then loop back to 1
    • If No, continue flow

If you want to go crazy, you can variablize the wording of that question so it's different after the first upload, i.e. "Would you like to add an attachment?", then after that, "Would you like to add any more attachments?".
I kept it simple with that universal wording though 🙂

Vijaya13
Tera Contributor

Yes, it worked... Can you also help with the below query?

https://community.servicenow.com/community?id=community_question&sys_id=00e731cfdb5a4910904fa9fb13961924

Whenever I do this the first attachment disappears, presumably overwritten?

It should not overwrite it. Every time you do a File Upload, it should be a new file (sys_attachment record).

See if this visualization helps - this is my Add Attachment topic block:

ChrisD_0-1712769625501.png

The canWrite logic is something unique to us - we needed to allow users to attach files to records that they don't normally have write access to, which prevents ootb vaSystem.attachToRecord()* - done from the "Attach file to record" script - from working. If the user doesn't have write access, I instead use GlideSysAttachment.copy() to copy the attachments from the current sys_cs_conversation_task to the specified record (in the topic block input).

*Also note that in Washington DC, you no longer need this line of code and you can use the ootb Update Record action to attach the file to a record with no code. This too adheres to ACLs and requires the user to have write access to the record.

 

Does that help?