In some situations you may need a CRM Action to return parameter and to implement the parameter values into a formula. Below is an example of how this can be be implemented.
We have a variable SaleTaxRate defined in a Process Action which can be called by multiple entities when needed. We require this to be integrated into a North52 formula to calculate the tax rate and consequent total amount for the estimated value in an Opportunity.
N52 Formula Manager Solution
The Formula Manager solution works like this:
- On save of the Opportunity record, the 'Est. Revenue' field is checked for a new or updated value
- If the value has changed, the formula is triggered
- This formula uses the function GetActionOutputParameter() to pull back the salestaxrate set by the Process Action new_SetSalesTaxRate
- This value is used to calculate the values for the 'Est. Sales Tax Amount' and the 'Est. Total Amount' which are then saved to their respective fields
N52 Action Creation Steps
For this example, a Action process will need to to be created that will store the variable saleratettax which is to be used by our formula.
The following set of steps outline how to create this
- Go to Settings > Processes
- Click New
- For Process name enter Set Sales Tax Rate
- For Category , select Action
- For Entity , select Opportunity
- Click Ok
- Open up this new process.
- Ensure that the Unique name is new_SetSalesTaxRate
- Under Hide Process Arguments , click the + sign
- For Name , enter SaleTaxRate
- For type, choose decimal
- Tick Required
- Scroll down and click Add Step > Assign Value
- Click on Set Properties
- Under Statement Label , enter SetSalesTaxRate
- Under Name choose SaleTaxRate
- Under Value enter 9
- Click Save and Close
- Click Save
- Click on Activate.
N52 Formula Manager Steps
The following set of steps outline how to create this Formula:
- Create a new formula of type Save - Perform Action
- Set the Mode to 'Server Side'
- Set the Event to 'Create & Update'
- Set the Source Entity to 'Opportunity'
- Set the Source Property to 'Est. Revenue'
- Go to the Formula editor
- Copy and paste the formula below
- Click Save
- It is now ready for testing
SmartFlow( SetVar ( 'saletaxrate' , GetActionOutputParameter( ExecuteAction('new_SetSalesTaxRate', 'opportunity', [opportunity.opportunityid]), 'SaleTaxRate', '0') ) , UpdateRecord('opportunity', [opportunity.opportunityid], SetAttribute('new_estsalestaxamount', GetVar('saletaxrate') * [opportunity.estimatedvalue] / 100 ), SetAttribute('new_esttotalamount', [opportunity.estimatedvalue] + GetVar('saletaxrate') * [opportunity.estimatedvalue] / 100 ) ) )
Wizard - ExecuteAction
Please see below the wizard you can use to create the ExecuteAction() function call used in this formula.
Note you will need to create the Action beforehand. To find the value for Record ID, you will need to go to the Sourcetab and search for "Opportunity"
Did you know?
North52 Decision Suite helps streamline complex business processes
North52 Decision Suite is a cloud-based or on-premise decision management/decision engine platform for the Dynamics 365 and Power Platform that uses data, analytics and business rules to automate decisions.
Companies use North52 to streamline their processes, improve the quality of the decisions inside their Dynamics 365 systems, and shorten the time it takes to adjust to business and competitive changes.