Create a Daily Microsoft Dynamics 365 Workflow


A Dyn365Pros client requested integration with an external system in order to pull account and invoice records into Dynamics 365. While many integrations with Dynamics 365/CRM are real time, this request has to pull records from the system just once per day. We had to solve one tricky issue in that there wasn’t a time stamp on the record changes to use as criteria to extract the records. That left us with the option of daily pulls. So we decided to create a daily Microsoft Dynamics 365 workflow that pulled the needed records. This could be done as a server task but we’re integrating an online instance.

Thinking it Through

After building out the custom workflow activity, we need to create workflows to run daily. We also want to keep track of the jobs and the results. The custom workflow activity returns results such as records pulled and the success of the import/update of records. To complete this solution, we created two records. The first was for configuration data to use with the integration and the second was the “job” record.  The job record is used as the trigger of the job.  The job record contains the date of the last run and is named for the integration. This is used to pull the records changed.

Microsoft Dynamics 365 workflow

The Set-Up:

The workflow is triggered on creation of the job record and then waits a day to continue running.

Microsoft Dynamics 365 workflow

The integration steps run. The results of the integration are placed in the job record. This is a simple workflow as requested by our client. The output of the integration is placed in the run record.

Microsoft Dynamics 365 workflow

This is especially helpful if the custom workflow activity throws an error. A new job record is created with the date of the run. This is stored in the name of the record and the “Last Run” field. The creation of the record will trigger the next workflow. And finally end the process.

While this is a simple workflow, there are other options we could put in place. We could incorporate a check step with each step to confirm the results and send email messages to the support team if there is an error/issue. The process could also trigger other process like a process to roll up values that cannot be rolled up with out-of-the-box fields.

Coming Soon…

Next time, I’ll use this process to run against a workflow with a custom workflow activity that runs against child records.

By Sanford Mosby, Microsoft Dynamics 365/CRM Technical Consultant, Dyn365Pros, Microsoft Dynamics 365 partner, San Diego, Southern California. Contact us.