In integration scenarios, Dynamics CRM actions, plugins, and workflows are some of the extension points that can be used to augment system behaviors for great flexibility. Actions, in particular, provide the ability to perform logical operations and return a set of values as its output, which, if used within our SSIS data flow design, would be beneficial. Using the recent versions of our SSIS Integration Toolkit for Dynamics 365, you can easily handle these output values and use them in your SSIS data flow process.
Actions in Dynamics 365 CE/CRM instances are defined as processes that can be triggered by a specific application, code, or another process. These have the ability to implement business or operational logic, such as checking for a set of conditions, assigning values based on those conditions, sending emails, checking another condition, and more. An action can take inputs, either as external arguments or from within an entity, and produce output parameters that can be used to produce output values as a result of the Action. Now, when you create an action, it gives you the flexibility to configure the various steps involved. For example, if you wish to verify whether an Account satisfies certain conditions, and if it does, then proceed to perform some steps, or if not, then proceed with another set of steps—these types of conditional branching and decisions can be easily automated by using Actions and its properties. An Action can be created either linked to an entity, deriving the fields from the entity itself along with input arguments, or as a global action, not tied to an entity, and working solely based on the input arguments.
When working with KingswaySoft Dynamics CRM components, we provide an option called ExecuteWorkflowAction in the CRM Destination component, which you can use to execute a workflow or an Action. On the general page, you can choose the Action discovered from a list of available processes, and on the Columns page, you can provide the Input parameters or arguments, if any. Additionally, in our recent versions (Since v23.1), you can also get the output arguments as a part of the Default output, giving you the ability to use the output for further data flow logic and design.
In this blog post, we will be demonstrating how to configure an action, trigger it using the KingswaySoft CRM Destination component, and capture the output for further processing.
Creating an Action within Dynamics 365 CRM Instance
First, we will create an action in the CRM instance. For this, we need to navigate to the Advanced Settings and choose Processes from under Process Center. Here, click on New to open up the CreateProcess window.
Here, provide the Process Name, and select the category as Action. You could leave the Entity blank if you do not wish to tie it to any specific entity. In our case, we are selecting the Account entity. For Type, since we are going to create the steps from scratch, we will choose New blank process. Click on OK, which will open a new window to enter the general properties associated with the Action.
Once here, create an Argument called PreferredCustomer, set the datatype as boolean, and the Direction as Output. This is what we will be using to read back the result of our Action within our SSIS design. We do not need Input Arguments, as our conditions will be based on Account entity fields. We will see how this is done in the upcoming section. Now, we need to create steps to perform the Action. Our use case is as follows:
Check to see if the specific Account (which is identified by using the AccountId) has a Credit Hold or not. If it does, then the Account is not a preferred customer, and we would set the output argument PreferredCustomer to False. Otherwise, if there is no Credit Hold, then we check to see if the Credit Limit exceeds a certain amount along with the Relationship Type. If it passes the conditions, then set the PreferredCustomer output to True.
For the above use case, we would create the Action steps as shown below by clicking the Add Step button and by branching conditionally.
When you set properties for the steps, the window below is what you would use to choose either the arguments or the entity metadata fields. In our case, as mentioned earlier, we will use the entity fields. The AccountId to be validated against will be provided in our SSIS design, and we will see how that is done in the next section.
Once configured, let's save and close the Action. Then, we Activate it.
Next, we move to the SSIS package to configure the CRM/CDS Destination component to consume or trigger the action.
Data Flow to Trigger the Action and Capture the Output
In our SSIS data flow, have a Source Component ready with the AccountId, Account Names, etc., that you wish to perform the Action against. Connect it to the CRM Destination component, and on the General page, choose the action as ExecuteWorkflowAction and select account as the destination entity. Now, choose the CheckCustomerStatus Action from the list. If you do not see your Action in the list, please cross-check if the Action is activated and is in the scope of the chosen entity.
On the Columns page, map the Input Column with the Account details against accountId. In our example, we do not have the AccountId in the Source system; therefore, we pass the Account Name and then perform a Text lookup against it. To know more on how to work with Text lookups, please refer to our Online Help Manual.
The AccountId retrieved from the lookup will be used to trigger the CheckCustomerStatus action that we have previously configured. On the Error Handling page, you will see that under Enable Columns for Default Output, the boolean output argument PreferredCustomer is available to be read back. This will hold the boolean value indicating whether the Account we have passed through is a Preferred Customer or not, based on the conditions set in the action.
Let's run the data flow. As you can see below, we are passing 4 account names to the CRM Destination, which has various CreditHold, CreditLimit and RelationshipType values respectively in the CRM instance. The Action is triggered to check against these, and we receive the boolean output as shown below.
Conclusion
As seen in our example, using our KingswaySoft Destination component, you can easily trigger an action and parse out the output, making it a very useful functionality for including additional validations or business logic in your SSIS data flow. Leveraging this feature, you can simplify the complexity of your design while at the same time expanding the scope of the package.
We hope this has helped!