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 BPA Solution

The North52 BPA 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


  • 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


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.):
                      ExecuteFormula('Ig9', '', SetFormulaParameters('radius', [account.new_sphereradius])))))
  • Click Save


  • 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?

You can easily build Fast and Accurate automated Tests with TestShield

No scripting or development is required. Our point and click editor enables non-coders to build automated tests for Dynamics 365 much faster and easier than traditional automated testing systems. 

Test Data and rules are stored in easy to maintain Excel-like sheets making it fast and easy to learn how to use TestShield.

Learn more about TestShield