Views:

Overview

This example shows how a user can execute a formula from inside another formula using a function called ExecuteFormula and a formula type called Library Calculation.

This can be useful when a set of steps are used often - having a centralized custom function setup and available allows for ease of access and is simpler to update. 

In this example, we wish to calculate the surface area of a sphere using a centralized formula.

Note: we will use two custom fields called Sphere radius and Sphere surface area.

North52 Decision Suite

The North52 Decision Suite solution works like this:

  • A formula is setup that triggers whenever the custom field Sphere radius changes on an Account
    • This formula will execute another Library Calculation formula
      • The first formula will pass the new Sphere radius value as a parameter into the Library Calculation formula
      • The Library Calculation formula then calculates the surface area of the sphere and passes back the value to the initiating formula
        • Our example uses an xCache record to reference the value for Pi
    • The first formula uses this new value to update the Account record field Sphere surface area

xCache 

  • Navigate to Settings > N52 xCache
  • Click New
  • Set Category to LibraryCalculations
  • Set the Base Key to LibraryCalculations_Pi
  • Set the Value (Secured) to 3.14159265358979323846
  • Click Save

Formula

Library Calculation Formula

  • Navigate to Settings > N52 Formula
  • Click New
  • Set Source Entity to N52 Command
  • Set Formula Type to Library Calculation
  • Select Classic Editor
  • Click Create
  • Set the name to Calculate the surface area of a sphere
  • Open the advanced editor and enter the following formula:
    4 * xCacheGetGlobal('LibraryCalculations_Pi') * Pow(CDecimal([north52_command.radius]), '2') 
  • Click Save
  • Make a note of the Short Code in the top right hand corner, you will need it for the next formula

Standard Formula

  • Click New
  • Set Source Entity to Account
  • Set Formula Type to Save - Perform Action
  • Select Classic Editor
  • Click Create
  • Change the name to Recalculate sphere surface area
  • Expand Source & Target
    • Select Sphere radius
      • Note: this is a custom field, you will need to create it
  • Open the advanced editor and enter the following formula (Note: you will need to swap the below Short Code (Ig9) with the Short Code of your formula. 'new_spheresurfacearea' is a custom field which you will need to create.):
    Smartflow(
    
      UpdateRecord('account', 
        [account.accountid],
        SetAttribute('new_spheresurfacearea',
                      ExecuteFormula('Ig9', '', SetFormulaParameters('radius', [account.new_sphereradius])))))
  • Click Save

Testing 

  • Open an Account record
    • Make sure the two custom fields are added to the form
  • Make a change to the Sphere radius
  • Click Save
  • You should see the results in the Sphere surface area field:

Did you know?

North52 helps Insurance Providers manage complex rules in their Dynamics 365 systems

The North52 Decision Suite helps insurance professionals manage the thousands of rules that form insurance approval, rate and commission calculations. Our easy to use, point and click interface allows for quick updating of rules by knowledgeable insurance analysts without programming experience. We assist in processes such as:

  • Task checklists
  • Quote calculations
  • Product configuration
  • Pricing
  • Commissions
  • Claims handling

Learn more about the North52 Decision Suite