How to include attachments from Interaction (CSM Workspace) into Flow Designer

Wivi
Tera Contributor

Hello,

 

I'm hoping in get some ideas and perhaps a solution to overcome a issue I'm currently facing. 

 

The scenario:

I created a simply flow to fire away an email to an external group (that will act as a third party resolver group on specific INC and RITM tickets), however this email should include any attachments from the original email sent by client/requestor (in special the ones that contains images), this way the third part group can work on the ticket and send it back to us to complete and close the INC or RITM. 

The issue: the attachments are coming from the original email into the interaction on CSM Workspace and is currently not being copied over the Case. Is there a way I can refer the attachment from the interaction into the flow created on the "send email" action? 


Flow details for context:
Trigger: Created or Updated
Table: Case 
Conditions: a couple of conditions to restrict that the appropriate INC or RITM will be handle over by this resolver group


Actions: Send Email
Target Record: Trigger - Record Created or Updated

Table: Case
Body: combination of text and all necessary data pills with relevant information

Appreciate any help, thanks!

3 REPLIES 3

Punit S
Giga Guru

Based on your specific requirement,  here is a step-by-step process for attaching an attachment from  interactions to a case record in ServiceNow CSM using flow designer:

  1. First, navigate to the Flow Designer in your ServiceNow instance by searching for "Flow Designer" in the application navigator or by navigating to "Flow Designer" under the "Workflow" section of the main menu.

  2. Once you are in Flow Designer, click the "Create Flow" button to create a new flow.

  3. Give your flow a name and description and then click "Create."

  4. Next, add a "Trigger" block to your flow by clicking on "Add Trigger" and selecting "ServiceNow Trigger."

  5. In the ServiceNow Trigger configuration, select "Interactions" as the table to monitor for changes.

  6. Click "Save" to save your trigger configuration.

  7. Next, add an "Action" block to your flow by clicking on "Add Action" and selecting "ServiceNow Action."

  8. In the ServiceNow Action configuration, select "Cases" as the table to create or update a record.

  9. Set the "short_description" field to the value of the "short_description" field from the interaction record by clicking on the "+" button next to the "short_description" field and selecting "Get Value from Previous Step" and then selecting the "Interactions" trigger block and the "short_description" field.

  10. Set the "description" field to the value of the "comments" field from the interaction record by clicking on the "+" button next to the "description" field and selecting "Get Value from Previous Step" and then selecting the "Interactions" trigger block and the "comments" field.

  11. Click on the "+" button next to the "attachments" field and select "Add Object."

  12. In the "Add Object" configuration, set the "name" field to the value of the "attachment_name" field from the interaction record by clicking on the "+" button next to the "name" field and selecting "Get Value from Previous Step" and then selecting the "Interactions" trigger block and the "attachment_name" field.

  13. Set the "content_type" field to the value of the "attachment_type" field from the interaction record by clicking on the "+" button next to the "content_type" field and selecting "Get Value from Previous Step" and then selecting the "Interactions" trigger block and the "attachment_type" field.

  14. Set the "data" field to the value of the "attachment" field from the interaction record by clicking on the "+" button next to the "data" field and selecting "Get Value from Previous Step" and then selecting the "Interactions" trigger block and the "attachment" field.

  15. Click "Save" to save your ServiceNow Action configuration.

  16. Finally, click "Activate" to activate your flow.

Your flow is now active and will create or update a case record in ServiceNow CSM with the information from the interaction record and attach the attachment from the interaction record to the case record.

 

Please mark my answer correct/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal. 

Thanks,
Punit

Wivi
Tera Contributor

Hi Punit,

Thank you for sharing the above steps. Although I was not able to reproduce them, I was successful and trying another approach by creating an action to copy the attachments from the interaction table into the case table and sent the email with the originals attachments. 
It was a combination of information from both of those questions previously raised here:
Solved: Using Flow Designer, add attachment to Send Email ... - ServiceNow Community
How to copy Attachments from Email to Interactions - ServiceNow Community

Regards

Amit Gujarathi
Giga Sage
Giga Sage

HI @Wivi ,
I trust you are doing great.

 

you can refer to the attachment from the interaction into the flow created on the "send email" action by using the "Attachment Documents" related list on the Interaction record.

You can use a script action in your flow to retrieve the attachment documents from the Interaction record and attach them to the email. Here is a sample code snippet that demonstrates how to do this:

(function execute(inputs, outputs) {

    // Get the interaction record
    var grInteraction = new GlideRecord('live_message');
    grInteraction.get(inputs.target_record.sys_id);

    // Get the attachment documents related to the interaction
    var grAttachmentDoc = new GlideRecord('sys_attachment');
    grAttachmentDoc.addQuery('table_name', 'live_message');
    grAttachmentDoc.addQuery('table_sys_id', inputs.target_record.sys_id);
    grAttachmentDoc.query();

    // Create the email message with attachments
    var email = new GlideEmailOutbound();
    email.setSubject('Your email subject');
    email.setBody('Your email body');
    email.addRecipient('recipient@example.com');
    while (grAttachmentDoc.next()) {
        email.addAttachment(grAttachmentDoc);
    }
    email.send();

})(inputs, outputs);

 


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi