T#2: Email customized weekly Report

Updated: Jan 23, 2019


Client: I need a weekly email report per opened opportunity, each emailed to the deal's owner on Fridays at 10am.


Dynamics Consultant: Flow!!


How is it done?

What to pay attention at?

Can we include in the email's body a direct link towards the Dynamics records?


The answers and more in the 10 steps below:


1. Connect to flow:

Click on the upper right corner, then click on Flow.



2. Create a new flow:

Click on "My flows" then on New -> Create from blank





3. Trigger the flow:

Search for the Recurrence trigger and choose it as a trigger.



4. Configure the Recurrence:

Frequency=Week

Interval=1

Day=Friday

Hours=10

Minutes=0

The preview will automatically show the final result.



5. Retrieve a list of records

Click on New Step, filter by Dynamics 365 and choose the action: List of records.



6. Configure and Filter retrieved records:

Choose the Organization name and the Entity name then filter the records to be retrieved.

Few examples concerning the Filter Query:

Example 1:

statuscode eq 1 or statuscode eq 1000001


Example 2:

stringfield eq 'stringtext1' and stringfield ne 'stringtext2'


Example 3:

startswith(Name, 'Online')


More examples can be found on the following link:

https://docs.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)




7. Add an "Apply to each" control:

Attach it to the List of items value we've just setup.

Then click on Add to action inside the "Apply to each" control.

This control will make a loop on the records we need to retrieve in order to send the multiple email reports.



8. Get Dynamics 365 Records:

In case your need to use inside your report Lookup fields from within the main entity, you will need to retrieve those records (even if what is needed is only to show the name of the lookup record).



In our case, we will get the Account record and the Owner of the opportunity record.

For each of these fields:

Choose the action "Get Records" and fill the Organization Name, Entity Name and Item Identifier.

Few tips for the Item Identifier which is a little bit tricky:

You can choose it dynamically or type its code version.

If you choose the pick up method, notice that a whole section of fields can be shown and hidden via clicking on "show more" or "show less".

The section "List records" with the "Show more" at its right must be clicked out in order to reach the fields of the opportunity records that flow will be getting throughout the loop.

As seen in the figure below, the opportunity fields are now displayed correctly below and we can choose the Account field.


A very useful tip here, not to forget, is to rename the Get record action in order to identify that record in a better way on the future steps.

NB: If you add an action that follows this one you will no longer be able to rename the record.


Rename "Get record" to "Opportunity.Account" for example.


The same steps are followed to retrieve the User behind the owner field on the opportunity to which we will be sending the email. Here is the result:


NB: Watch out to pick the Opportunity.Owner field and not the Account.Owner field (Unless the opposite is what you need).



9. Add a "Send email" action and configure the Email to be sent.

Add an action and filter by "Send email" then pick the Send an email through office 365 outlook.



Click on "to" and choose the option "show more" on the Opportunity.Owner dynamic record then pick up the right email address field.

Do the same to fill in the Subject dynamically if needed as well as the Body.

In order to send what I call a "Sexy" report, you can type inside the Body html code email.

To do so, click on "Show advanced options" then switch to yes the "Is Html" field. By writing out your email in Html coding you will be able to add all text formatting options.


Few html coding tips for functional consultants:

</br> : return to the line

<b> your text here </b> : (text in bold)

<u> your text here </u> : (underlined text)

<i> your text here </i> : (italic text)

<FONT COLOR="#990000"> your text here </FONT> : (Hexadecimal, colored text)

Note that you can combine any of these, for example: <b><u>Opportunity: </u></b> gives the text in bold and underlined.


The body field of the email looks pretty small at first, but you can press as many "enter" as you need in order to make the section bigger and type in your html code.


Accessing Records through your report:

A very nice trick while using the Unified Interface to point out to the Opportunity record in CRM through your report: (html code)

Enter to the unified interface then access any opportunity record in your crm.

Now copy and paste the URL that you get.

It must look like that: https://yourdynamicsurl.crm4.dynamics.com/main.aspx?appid=9501571e-63fd-e811-a95c-000d3ab5a3d9&pagetype=entityrecord&etn=opportunity&id=

As you may have noticed, the last part after "opportunity&id=" is the record ID that we need to add dynamically through the "Dynamic content".

Since a text pointing to the URL record is always better, here's an HTML example you can follow:

To access the opportunity record click <a href="https://yourdynamicsurl.crm4.dynamics.com/main.aspx?appid=9501571e-63fd-e811-a95c-000d3ab5a3d9&pagetype=entityrecord&etn=opportunity&id= YOURDYNAMICID">here</a>.


The text appearing in your email will be: To access the opportunity record click here



10. Test your flow then Publish:

Before going live, filter the list of records in a way to have the email only sent to yourself.

Save your flow.

Click on "Flow Checker" to verify that no errors occur.

Click on "Test" and choose "I'll perform the trigger action" in order to test the HTML of your email.


Confirm your choice by clicking on Run flow.

You will be able to see by then the results of the manually triggered flow, record by record - Email by email.

NOTE: the Test will effectively SEND the emails to all the owners of the retrieved opportunities in our case.


Whenever your tests succeed, do not forget to put back the correct filters, Save and Publish!


To conclude, it is easy to switch your flow between different environments by changing the Organization name in all the correspondant Triggers/Actions.

0 views
Never Miss a Post. Subscribe Now!

© 2019 by Joseph Merhej 

  • Grey Instagram Icon
This site was designed with the
.com
website builder. Create your website today.
Start Now