cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Dynamics 365 - Use flow to take an attachment from an email on an opportunity and place it in the specified Sharepoint Location for the Opportunity?

I am trying to trigger a flow when an email record is created.  I use a condition that it is regarding an opportunity.

Then I want to get the attachment from the email and put it in the Opportunity's Sharepoint file location.

 

1. I have seen solutions stating "get attachment" but I do not see this flow option with Dynamics 365.  Can I use the "attachment" entity?

2. How do I find the Sharepoint location regarding the opportunity?

 

Thanks in advance community.

4 REPLIES 4
Highlighted
Community Support
Community Support

Hi @colbournescott,

 

1. You can get the attachments from the email, then store them into the attachment entity, then you can create the association between the opportunity entity and attachment entity.

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/associate-disassocia...

2. Or you can store attachments into the SharePoint list, then create the association between the opportunity entity and SharePoint list.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Super User
Super User

Hi @colbournescott 

 

1. Use the CDS connector to get the Attachment record associated with the email. You can find this by querying the activitymimeattachments entity where the objectid is equal to the guid of the Email record. Then use the base64ToBinary function in Flow to convert the body property of the attachment record, the output of which you can use in step 2 below.

2. The SharePoint location for each record should be available by querying the Document Location (sharepointdocumentlocations) entity where the regardingobjectid is the guid of the Opportunity record. Once you have the Document Location associated with the Opportunity record you can use the SharePoint connector to create the file in SharePoint, using the Relative URL field from the Document Location. The filecontent property in the Create File in SharePoint action should be set to the value you generated in step 1 above using the base64ToBinary function.

 

The file should then be visible in the Documents tab of the Opportunity within Dynamics 365 and safely stored in SharePoint. One thing to look out for when querying the Document Locations is that they won't exist if the Documents tab has never been viewed on the record in Dynamics. If this is the case you just need to add some additional steps to create this. I have used this article to achieve something similar using Note attachments (https://community.dynamics.com/365/customerservice/b/futurezconsulting365ce/posts/flow-examples-note...).

Hope that helps point you in the right direction.


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Highlighted

Hi @LeeHarris 

 

Came across this today when looking for a solution to this issue.  Your solution worked for me.  Thanks a lot!

Highlighted
Kudo Commander
Kudo Commander

I also found a blog post about "Move Attachments from Tracked Email to SharePoint using Microsoft Flow". Even though the blog post was written before CDS connector is available, it should work with CDS connector too.

https://www.cloudfronts.com/move-attachments-from-tracked-email-to-sharepoint-using-microsoft-flow/

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,681)