By combining global variables with chaining integrations together, users can pass data to the next integration – either to be used in the data source of the second integration, or as part of the additional columns.
One common scenario is where a transaction (i.e., an invoice) is being generated in Dynamics CRM/CE and sent to the financial system. In this example, we’ll use Dynamics 365 Business Central. When the invoice is sent across, we want to record the CRM invoice number or name in Business Central, but then also send the generated number from BC back to CRM.
We’ll accomplish this using 2 integrations, 1 global variable, and the Run Integration Task. We’ll use a real-time integration to send the invoice from CRM to BC, and we’ll be sending the Invoice Name field to the Your Reference field in BC on the invoice. This determines how/what we use our global variable to track.
First, we’ll create a global variable that is named to represent the data we will be storing in it. In this example, this is the Invoice Name being sent to the Your Reference field. This can be done in the Maintenance section of SmartConnect.
We will need to store the Invoice Name value in a global variable so we can reference it in the data source of the second integration in order to write back the document number to CRM that BC generated for our invoice. This can be set in the Restriction of the first integration, since we have the data being passed through and we are dealing with just one record at a time.
We now can save that integration and start looking at the integration that will be writing the data back to CRM. In this case, we’ll be using a bulk source to pull the data from BC but adding the global variable that we are passing through to restrict it to the one specific record we just created. The source query would look similar to the following, where we query the invoice service from BC but add the filter to it:
That data source should then be attached to the integration that will be writing the data back to CRM. In this scenario, the integration will simply be using the Your Reference field as the key/grouping field when sending back to CRM, and then writing the “No” (Document Number) field from BC to a field that will hold it in CRM. That mapping should be created, and the overall integration saved before continuing.
Run Integration Task
The final step is to tie the 2 integrations together using the Run Integration task. Opening the original real-time integration from CRM to BC and navigating to the Tasks menu allows it to be created. In the task, the option for “Use Parent Variables” should be selected.
Once that task is configured and saved, the process should be complete. Anytime the real-time integration sends a new invoice to BC from CRM, the global variable and task will ensure that the second integration immediately runs afterward and sends the BC document number back to CRM because of the global variable filtering it down to just the one record.
This concept can be used for any other integrations that are similar to the scenario above. It is important to remember though that real-time integrations are best for using global variables in this manner, since it is only one record at a time which allows the global variable to be set and passed through for the data.
If you have any questions about using global variables or SmartConnect, feel free to reach out to us at email@example.com