Views:

Scenario Overview

In this scenario the business requirement that needed to be solved was related to tax on Order Products

The customer wanted a simple way to update the Tax on all the Order Products connected to an Order. To solve this we added a custom tax field to the Order form that will hold the tax rate percentage. When this is changed the formula will calculate the value of the tax in each Order Product and update it accordingly.

N52 Formula Manager Solution

The Formula Manager solution works like this,

  • Formula of type 'Save - Perform Action' is created on the Order entity
  • Event is set to 'Create & Update'
  • Source Property is set to Tax

N52 Formula Manager Steps

The following set of steps outline how to create this Formula

  • Create a formula of type 'Save - Perform Actionon the Order entity
  • Set the Source Properties to 'Tax'
  • Copy and paste the formula below into the formula canvas
  • Save and test!

The Order with no tax percentage set.

After the Tax is set to 12.5%

The 50 Bicycles with the 12.5% tax applied.

Formula 

if(containsdata([salesorder.new_tax]),

  ForEachRecord(

    FindRecords('salesorderdetail', 
                'salesorderid',
                [salesorder.salesorderid], 
                SetFindSelect('salesorderdetailid','baseamount'), 
               '50', true),

    UpdateRecord('salesorderdetail',
      CurrentRecord('salesorderdetailid'),
      SetAttribute('tax', (CurrentRecord('baseamount') * [salesorder.new_tax]) / 100)
    )
  ),
  'NoOp'
)

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 "Order" , click on Order