17 Oct’18

D365 GeneralMove Attachments from Tracked Email to SharePoint using Microsoft Flow

Introduction:

Microsoft flows can be used to automate many workflows across multiple applications and services. This is basically designed for non-developers. To create a flow, the user specifies what action should take place when a specific event occurs.

In this blog, we will have a look on how we can add the attachments from the emails that are tracked in Dynamics 365 CRM to SharePoint

Systems included in Document Integration

  1. D365 App for Outlook
  2. SharePoint
  3. Dynamics CRM Online V9

Note: We have taken Opportunity tracked Emails for this example, you can work on any entity.

Let’s start with the steps that should be undertaken to achieve the above requirement.

Step 1:

Create a blank Flow template. Choose the Dynamics 365 Connector and trigger as, “When a record is created”.

Select your Organization Name, and the entity, in our case it is Email Messages.

Step 2:

Add condition to check whether the email is related to Opportunity and whether it has Status Reason as Received.

By default, the condition you can specify is basic. Change in to Advance mode and add the below formula

Formula used:

@and

(

equals(triggerBody()?[‘_regardingobjectid_type’], ‘opportunities’),

equals(triggerBody()?[‘_statuscode_label’], ‘Received’)

)

Step 3:

For the true part of the condition, retrieve the Opportunity record to which the Email is tracked. The reason behind retrieving Opportunity Name is to create SharePoint Folders. Folders will be created on the format Topic_OPPORTUNITYGUID.

 

Step 4:

Now let us retrieve all the Activity Mime Attachments associated with the Email Message that is created.

There are two Attachments entities available for the selection.

The first one is the Attachment entity

The second one is the Activity Mime Attachment entity.

Step 5:

Retrieve Attachment related to the Activity Mime Attachment for the Body and File Name of the attachments.

Now steps to check the presence of Document Location starts

Step 6:

Retrieve the Document Locations for the current opportunity record to see if there is an already defined path or not.

Select “List Records” action and enter below fields

Step 7:

After retrieving the Document Location records, verify the length of the records in the collection.

Formula used : length(body(‘Retrieve_Document_Locations’)?[‘value’])

Step 8:

For the true part of the condition, follow the below steps:

Step 8.1:

Select connector as SharePoint and select Create file Action.

Enter all the details listed below:

1) Site Address: The SharePoint Site Address

2) Folder Path: The path where the file need to be stored. i.e. /opportunity/Topic_ toUpper(replace(body(‘Get_record’)?[‘opportunityid’],’-‘,”))

For Example the folder Name will be :

Topic_E608E808F4A1E811A977000D3A37051A

3) File Name: Name of the file

4) File Content: The attachment body

Step 8.2:

Delete the Attachment record from the Dynamics CRM Email message.

Here you need to select the first option of Attachments from the list.

Step 9:

For the false part of the condition below are the steps you should follow:

Step 9.1:

Create a file in SharePoint. Refer Step 8.1

Step 9.2:

Retrieve the Parent Document Location. This is needed as we are creating the document location by ourselves.

Step 9.3:

Create the Document Location record for the record that was just processed.

Parent Site or Location: This is the GUID of the parent Doucument Location retrieved in Step 9.2

Relative URL formula: replace(replace(body(‘Create_file_3’)?[‘Path’],’/opportunity/’,”),concat(‘/’,body(‘Create_file_3’)?[‘Name’]),”)

Step 10:

Delete the Attachment record from the Dynamics CRM Email message.

Here you need to select the first option of Attachments from the list.

Now you can test by sending email and tracking to Opportunity in D365 App for Outlook in Dynamics CRM. Document will be uploaded to SharePoint with specified location.

Written by

Team Member

CloudFronts

Leave a Reply

Your email address will not be published. Required fields are marked *

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • How to create Dynamics 365 Finance & Operations (formerly Dynamics AX) connection in SSIS

    12 December’ 2019

    Introduction: Creating a Connection is one of the first Steps during the integration of data. While performing Integrati...

    Read more
  • How to create AX (D365 F&0) Connection in SSIS

    12 December’ 2019

    Introduction: Creating a Connection is one of the first Steps during integration of data. While performing Integration w...

    Read more
  • First cut review of new D365 Project Service

    12 December’ 2019

    The new Project Service coming up is a much-advanced version of PSA. Even more, than it will be called as Project Servic...

    Read more
  • Business Central Wave 2 Features – Section 4

    11 December’ 2019

    Introduction: In this blog, I will be attempting to provide information about the new Modern Client features of Business...

    Read more
  • Business Central Wave 2 Features – Section 5

    11 December’ 2019

    Introduction: In this blog, I will be attempting to provide information about the new Modern Client features of Business...

    Read more

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close