Scenario Overview
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.
Formula
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.
This says find the systemuserid for a systemuser record where the value in the fullname field equals Default Username
The signature of the FindValue function is:
If you need further help, please email our support team who will be happy to assist - support@north52.com