In the previous sample we saw the following requirement that we had a 3rd party integration creating Account records within Dynamics 365. This integration cannot set the ownerid field of the record but it can set a text field with the name of the owner. So we need to use this information to lookup the User ID value & set it to the owner of the Account record.
In this advanced scenario we need to set a default if no User ID is found when we use the Owner Text to perform the lookup.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- A formula is set to execute for the create event of the Account entity
- It checks that the OwnerText field has data before it executes the main formula
- The formula lookups & set a variable called 'LookupOwnerId'
- The formula lookups & set a variable called 'DefaultOwnerId'
- It checks to see if the variable 'LookupOwnerId' has data
- And sets the variable 'FinalOwnerId' based on this decision
- Finally it updates the Account record Owner field with the value in the 'FinalOwnerId' variable
North52 Decision Suite Steps
The following set of steps will set this formula up for you.
- Create a new formula of type 'Save - Perform Action'
- Set the Source Entity to 'Account'
- Set the Source Property to 'Owner Text'
- Set the Event pick-list field to Create
- Copy & paste the formula below into the formula description field
- Click Save
- Ready to test.
SmartFlow( SetVar('LookupOwnerId', FindValue('systemuser', fullname',[account.new_ownertext],'systemuserid')), SetVar('DefaultOwnerId', FindValue('systemuser','fullname', 'Default UserName','systemuserid')), SetVar('FinalOwnerId', if(ContainsData(GetVar('LookupOwnerId')), GetVar('LookupOwnerId'), GetVar('DefaultOwnerId'))), SmartFlowReturn( UpdateRecord('account', [account.accountid], SetAttributeLookup('ownerid', 'systemuser', GetVar('FinalOwnerId')) ) ) )
Note 1 : The formula has been written so it easy to understand.
However we can make this formula more efficient by combining the second & third SetVar() function calls. This would save us an extra lookup in relation to the default User ID when the first one exists.
Formula Cleaned Up:
SmartFlow( SetVar('LookupOwnerId', FindValue('systemuser', 'fullname',[account.new_ownertext],'systemuserid')), SetVar('FinalOwnerId', if(ContainsData(GetVar('LookupOwnerId')), GetVar('LookupOwnerId'), FindValue('systemuser', 'fullname', 'Default UserName','systemuserid'))), SmartFlowReturn( UpdateRecord('account', [account.accountid], SetAttributeLookup('ownerid', 'systemuser', GetVar('FinalOwnerId')) ) ) )
Wizard - ClientSideDate
Please see below the wizard you can use to create the ClientSideDate() function call used in this formula.
Note 2: to find the value for Equals Value, you will need to go to the Source tab and find the field.
Did you know?
North52's Data Packager helps move Portal configuration data between instances
North52 Data Packager can be used to easily manage the transport of portal data from one instance to another. Specifically for Dynamics/PowerApps Portals, we provide templates that let you quickly move all portal entity data with ease. You can move whole sites or only the records you specify, either manually or via FetchXML queries.
And, because we use the Solution framework for the export and import of Data Packager data, you can easily version each data package. This is especially useful if you need to build up a new dev/test portal to a specific version – just apply and execute the Data Packages you need.