In Dynamics 365 CRM, a timeline allows users to view a chronological list of activities, notes, and posts related to a record. The timeline is available on the record form and can be customized to show relevant information. Overall, the timeline in Dynamics 365 CRM is a useful feature that allows users to quickly view the history of activities related to a record and stay up to date with the latest information.
In this blog we are trying to show the attachment from an email as notes in the timeline. For the demonstration we are using a table named Agreement. There is an email field in the agreement table. Let us assume that there will only be one record with each email address.
Let us start the flow by adding the trigger 'When a new email arrives (V3)'.
Set the folder to
Inbox, Include Attachment to
Yes, Subject Filter to '
For Testing' and Only with Attachments to
Yes. Since the above filter criteria are given, only the email falling in inbox with attachment and subject '
For testing' will trigger the flow.
Next add the action 'List Rows'.
In this step we will filter the record in the Agreement table with User Email address equal to the received email from address.
As we discussed there should be only one record in Agreement table with each Email address.
Now we will get the attachment from the received mail by using the action Get Attachment (V2).
Add the Message Id and Attachment Id obtained from the trigger step.
We retrieved the attachment file from the email and fetched the record to which the attachment is to be attached. All we have to do is to add the attachment to the Notes. But before that we need to convert the file to Binary.
Add a new compose step and add the expression
base64ToBinary(outputs('Get_Attachment_(V2)')?['body/contentBytes'])
Next step is to add the file to Notes table. For that we can use the action 'Add a new row'.
The base64ToBinary output should be converted to Base64 and added to notes.
base64(outputs(Compose))
Give a unique title for the note and provide an appropriate description. Set the Is Document field to Yes and in the Document field give the expression
base64(outputs('Compose'))
The File Name must contain the Name obtained from Get Attachment (V2) step. Because the extension of the file is available in the Name dynamic content.
Also, the Regarding (Agreements) field should be filled with agreement unique identifier as shown in the above figure. This binds the note attachment to the specific Agreement record.
Combining all the above explained steps, the flow looks like this.
If I receive an email with an attachment and subject as 'For testing'. The flow triggers and check in Agreement table for a record with user email equal to the received email address. If a record exists, the attachment of the received email ill be added to the timeline of the particular record.
Comments
Post a Comment