Here we show you how xCache can be used to handle variables that change after a specific date.
For this example we are going to use Sales Tax (%).
We will assume the standard Sales Tax percentage is 13%. However from the 1st January 2017 the Sales Tax rate is being increased to 15%. We want this years Sales tax to automatically display on the invoice form when it opens only if the Status of the invoice is Active.
All invoices in 2016 will display the 13% rate and in 2017 they will display the 15% rate.
For this we will create 2 xCache records with xCache Key Effective Dates
N52 BPA Solution
The BPA solution works like this,
- We create 2 xCache records in CRM
- Both have the same Category and Base Key, but different values for Record Start Date and Record End Date
- For each xCache record we enter the tax amount for that year
- When the form loads it will automatically display the correct sales tax amount to the end user
Configure the formula
The following set of steps will set this formula up for you:
- Create a new formula of type ClientSide - Perform Action
- Set the Source Entity to Invoice
- Create a new field on the invoice form called Sales Tax (%)
- Copy and paste the formula below into the formula description field
- Click Save and then test
Active invoice in 2016
Active invoice in 2017
if([invoice.statecode] = 0, SetClientSideField('new_salestax', xCacheGetGlobal('Sales_Tax')), 'NoOp')