Using Custom Scripts in Business Rules

Custom calculation scripts contain sections of code which can then be referenced several times within a Business Rule, or in multiple different Business Rules. They are created within Calculation Manager, in much the same way as Business Rules, and are listed below the relevant PBCS Plan Type, under the ‘Scripts’ heading, as below:

Custom scripts are useful for times when a certain section of code is repeated throughout a Business Rule, or is contained in multiple Business Rules. Using scripts in this situation means that if the script needs to be altered, it only needs to be updated in one place, rather than having to be updated in multiple locations or Business Rules. This saves time and ensures all your Business Rules which contain this section of code are consistent.

The syntax used to reference a script from within a Business Rule is:
%Script(name:="ScriptName",application:="AppName",plantype:="PlanType")

Where: 
  • ScriptName is the name of the script (e.g. AGG_Script)
  •  AppName is the name of the PBCS application (e.g. Hyperion) 
  • PlanType is the name of the PBCS cube which contains the script (e.g. Retail)
Note: The script reference syntax does not need to be followed by a semi-colon

By right-clicking on a script, it is possible to view all usages of that script. This means you can see which business rules reference this script, who wrote the rule and whether each rule has been validated and deployed.

This is useful after editing the script as all Business Rules which contain that script must be redeployed before the script changes will take affect for users. The script itself does not need to be deployed.

Other useful features of custom scripts:
  • They can be used within a FIX or an IF statement
  • They can contain substitution or user variables
  • They can contain combinations of any standard functions or SET commands
  • They can contain RTP (Run-Time Prompt) variables
  • Available in PBCS, EPBCS or On-Premise Hyperion Planning 

SCRIPT EXAMPLE
Below is an example of a simple aggregation script which can be used within various business rules for simplicity. The custom script is called ‘AGG_Script’ and contains the following code:
This script can be referenced in Business Rules which require an aggregation of the sparse dimensions. For example, a Business Rule called ‘Retail AGG All Actuals’ which aggregates only the “Actual” scenario in the Retail cube would read as follows:

We can then right click on the ‘AGG_Script’ script and select ‘Show Usages’ to view the names of all Business Rules which use this script, as well as their cube, owner and deployment status:

If the ‘AGG_Script’ Script is edited, the rule ‘Retail AGG All Actuals’ must be redeployed before the changes will take affect for users. The ‘AGG_Script’ script itself does not need to be deployed.

As mentioned previously, custom scripts are perfect for situations where a section of code is repeated throughout a Business Rule, or is contained in multiple Business Rules. This means any script changes only needs to be implemented in one place and ensures all your Business Rules which contain this section of code are consistent.

Comments

  1. This is so useful! Will definitely be using this going forward!

    ReplyDelete

Post a Comment

Popular posts from this blog

Loading multi-period row data files using Data Management

Executing Smart View Retrievals using VBA

Loading Actuals from Fusion ERP Cloud to PBCS