Scenario Overview

In this scenario we have a custom field on the Quote entity called Admin Fee. This field must be populated whenever a Quote is created. The CRM system has a custom entity which stores all the admin fees by Account, Category and Parent Account.

We need to write a formula which will populate the Admin Fee field on the Quote during creation. If no Admin Fee is found then we need to set a default of zero.

N52 Formula Manager Solution

The Formula Manager solution works like this,

  • A formula of type 'Save to Current Record' is created so that when the Quote is created the formula executes
  • The formula executes a fetch-xml query that returns the correct fee 
  • The formula passes in 3 dynamic parameters to the fetch-xml at runtime

N52 Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a new formula of type 'Save To Current Record'
  • Set the Event picklist to 'Create'
  • Set the Source Entity to 'Quote'
  • Set the Target Property to 'Admin Fee'
  • Copy & paste the formula below into the formula 
  • Click save


                     FindValue('account', 'accountid', [quote.customerid], 'parentaccountid' ) 

Formula Detail Steps

The following set of steps outline how to create the Formula Detail record (i.e. fetch-xml)

  • Create a new formula detailed called  'GetAdminfee'
  • Copy & paste the fetch-xml from below into the query field
  • Click save



<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="new_adminfeelist">
    <attribute name="new_name" />
    <attribute name="new_amount" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="accountid" operator="eq"  value="{0}" />
      <condition attribute="categorycode" operator="eq" value="{1}" />
      <condition attribute="parentaccountid" operator="eq"  value="{2}" />

Wizard - FindValue

Please see below the wizard you can use to create the FindValue() function call used in this formula. 

Note to find the value for Equals Value, you will need to go to the Source tab and search for "customer" 


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