Microsoft Flow – Report CRM Cases to Email

 

In the following example I am generating a report of CRM Dynamic Cases and sending it via email.

During my investigation I discovered that you cannot send reports directly from Dynamics, so using flows is a workaround. Not an easy one, but lets see.

 

First, we need connection to Exchange Online and Dynamics CRM.

We are going to get a list of cases, and then do a “foreach” loop to capture the Customer Name, which is stored in a different table, and populate an Array with this data.

Sorry about the localization in the example, I am working form an Spanish computer.





First we are going to start with a Recurrence of once per month, but you can choice wherever you want.

Then we are going to add “Common Data Service” – List records.

You can change the name, and add some filters if you want. In this example I am filtering cases of Statuscode 1 and from specific customer id.



Next step,. I am going to Initialize an empty array. Later I will fill this array with results.

You should seek for “Initialize variable” and set the type to “Array”.

In value, select formulas and write “null”.



Add a Control of “for each one”. This will allow you to travel from each result value and fill the array.



In the “Value” it belongs to the result of “List of Cases”, in the previous step.

Then you will get the Common Data Service “Get record”. This will get only 1 record, because we need to gather the customer name from another place, the Accounts entity. You should use this same example for different kind of data you need for your report.

Last, you will fill the array. Use the “append to array variable”. Select the name of the array you created before, and then you should write the code for the entry. In this example I am creating with Case Title, a customer Case ID, and our Customer Name.

{"Case Title":CASE_TITLE},"CustomerID":CASE_ID,"Customer":ACCOUNT_NAME}

Remember, this is an example, you must try using your own data, but keep the array syntaxis correct.

Next step, you should go away from the “foreach control”. And populate an HTML Table with the array results. This will help you for the email.



In last step, lets create our email. I recommend to use this html syntaxis and put the table in the body. Should do the work.



Code below:

<html>

<head>

  <style>

table, th {

    border:1px solid black;        

}

td {

    border:1px solid black;

    text-align:left;

}

  </style>

</head>

<body>

TABLE_OUTPUT

</body>

</html>

 

If everything went fine, you should try and receive a beautiful message


Here you can find the complete flow, as a picture for guidance.



Comments

Popular posts from this blog

Update DNS static servers in your local Network

Error 'General access denied error' (0x80070005). Starting SCVMM Resource

Powershell Scritp for Inventory VMS in Hyper-V and VMware