Flow is great, and just being able to point and click to build integrations is the thing that makes it so usable. But sometimes you want to be a little bit cleverer with your data and even use functions that remodel the data.
For example, when creating a new Customer within Dynamics 365 for Operations through Flow when a new Account is created in the Common Data Service, if you are like me, then maybe you will want to have a consistent naming convention, and you don’t want to use the standard Account ID that is created in the entity.
My customer naming convention is the first two letters of the Organization Name and then 4 digits, but I cannot change the default numbering format for the Account Id in the Accounts entity.
If I were doing this through Excel, then I would use this formula:
Upper(Left(OrganizationName)) & Right(AccountId,4)
But how do you do this in Flow?
The good news is that there is a special Data Operations service within Flow that allows you to create a function using data from the previous steps in the flow, and then you can use the output in subsequent steps.
Here is how you do it.
How to do it…
To start off open Flow and then create a new Flow by clicking on the + Create from blank link.
When the trigger event is displayed, search for the Common Data Service actions and select the When a record is created trigger event.
This will then create a trigger for you that needs to be configured.
Click on the The database dropdown list and select the default database.
Then click on the The entity dropdown list and select the Account entity from the list.
Now that we have the trigger which will fire when a new Account is created within the Common Data Service we want to add a step that will create our new account name from the data. To do this, click on the + New Step button and then select the Add an action button.
When the action browser is opened, search for the Data Operations service and then select the Compose action.
This will open a simple action that just has an Input field. This is where we need to create our function that will create our new Customer Number.
The function will be written in the Azure Workflow Definition Language and if you want to find all the documentation on it then here is the link:
To create the new customer number that is the first two letters of the Organization Name and the last 4 digits of the Account Id (since this is a sequential number) then just paste in this function:
“@concat(toUpper(substring(triggerBody()[‘OrganizationName’],1,2)),substring(triggerBody()[‘AccountId’], sub(length(triggerBody()[‘AccountId’]),4), 4))”
After you have done that just give the Flow a Flow name and then click on the Create flow button.
After the record has been published then you will see that the Account ID is created for the Account.
When you return to you Flow you will see that is has been triggered and if you expand out the Compose action then the Output is now set to the format that we want for our Customer Numbers.
Now that we have composed our new field we can now use it in future steps within the Flow. For example if you continue on and add another action that created the Customer within Dynamics 365 for Operations, but when populating the Customer Number field, we can now use the output of the Compose action.
How cool is that? (Rhetorical question)
Share this post