Now and then there is a need for some scheduled job to be done on Dynamics CRM, like every day check if some data is updated, some records deleted, mails sent, etc. In Dynamics CRM there is no a classic way of scheduling a job for this kind of processing. One way to do this, which will be explained in this post, is a process with waiting period that can be used to trigger some action in a predefined time. Using a process you can create some complex features for Dynamics CRM, which can call other processes/workflow/plugins inside it, insert some predefined records in entities or send an email.
In Dynamics CRM, there are 4 types of processes that can be created:
- Action – use to create a new operation that is not available in a standard Microsoft Dynamics CRM installation or to combine multiple disparate operations into a single operation.
- Business process flow – use to create a visualization of the business process flow. Users are guided through various stages of the sales or customer service processes. At each stage, you complete specific steps and then move to the next stage. You can customize the process flow by adding or removing steps, changing the order of the stages, or adding new entities to the process flow.
- Dialog – use to create an interactive step-by-step data entry form that requires user input to start and run to completion. When you start the dialog process, a wizard-like interface is presented so you can make appropriate selections or enter data as you progress through each page of the wizard.
- Workflow – use to model and automate real world business processes. These processes can be configured to run in the background or in real time and can optionally require user input. Workflow processes can start automatically based on specified conditions or can be started manually by a user.
More information can be found on https://msdn.microsoft.com/en-us/library/gg309471.aspx.
When creating a process using wizard, the user needs to choose for which entity is this process attached and the event that will trigger this process. Process can be triggered on some action that are done on chosen entity like new records created, deleted or changed.
For example if we need to schedule a day job process that will get some data from remote sites we can create a process that will trigger a plugin where we can implement a logic to connect to that remote site, retrieve data from it and insert that data into entities where they belong. Settings for this example would be:
After this configuration we needs to specify steps in process execution. First step would be to create a new record in Trigger Entity including information like when is started. Creating this record will trigger a plugin that will retrieve data and insert them in appropriate entities. After this is successful done, next step will be to wait the execution of this process for a day. After this step is finalized, this process will start create a new “Timed triggered process” as a child process and start it.