Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Defining distribution rules

Log in to subscribe to topics and get notified when content changes.

Defining distribution rules

To define new distribution rules, navigate to Financial Management > Admin > Distribution Cost Rules, and select New.

Populate the following fields:
Table 1. Defining Distribution Rules
Field Input Value
Name A unique name for the rule.
Active Determines if the rule is actively used.
Advanced If checked, the distribution rule will be determined by script. If not checked, it will be determined by table and conditions.
Description A description of the rules and any notes on its use.
Script If Advanced is true, the script which will determine the rule's behavior.
Table If Advanced is false, a list list of tables to find the records to distribute the cost to.
Condition If Advanced is false, a condition builder to determine which records will receive the distributed cost, on the table determined by the Table field. Cost amount will be distributed evenly across the records identified by the table and condition values. This field uses the Condition Count Widget to preview what records would be returned by the conditions.

Once submitted, the Distribution Costs related list will appear to determine which costs will be distributed according to the rules.

Scripted distribution

Scripted distributions allow for custom distribution amounts, versus the evenly split distributions when using table and condition filters.

To enable scripted processing on a distribution rule:
  • Check the advanced field check box, this will display the script field.
  • Build the script using the following concepts:
    • Query for target records and data to use for calculating the allocation amount.
    • Create expense line records using the DistExpenseLine API.
As noted in the default script, when the advanced field is enabled, the following variables are available during the script processing:
  • distCost - GlideRecord for the distribution cost, allowing access to all fields.
  • distCostAmount - cost amount in the system currency.
To create an expense line record, use the DistExpenseLine API
/* Available variables:
 *   distCost - GlideRecord for the distribution cost
 *   distCostAmount - cost amount in system currency
 * To create an expense line record use the DistExpenseLine API
 *   var DistExpense = new DistExpenseLine(distCost);
 *   DistExpense.createExpense(expenseSourceGlideRecord, amount, description);
 *     createExpense returns true if expense was inserted;
 * Sample Script to distribute a cost to departments based on number of	active users in each department
 */ //get the total cost from the distCost var deptUsers  = new GlideRecord ( "sys_user" ) ;
deptUsers. addActiveQuery ( ) ;
deptUsers. addQuery ( "department" , "!=" , "" ) ;
deptUsers. query ( ) ; var totalUsers  = deptUsers. getRowCount ( ) ;
 //get the count of users for each department var deptUsers  = new GlideAggregate ( "sys_user" ) ;
deptUsers. addActiveQuery ( ) ;
deptUsers. addQuery ( "department" , "!=" , "" ) ;
deptUsers. groupBy ( "department" ) ;
deptUsers. addAggregate ( "COUNT" ) ;
deptUsers. query ( ) ;
 //for each department calc amount and create expense line while (deptUsers. next ( ) ) { var dept  = deptUsers. department. getRefRecord ( ) ; var deptCount  = deptUsers. getAggregate ( "COUNT" ) ; var deptAmount  = distCostAmount  / deptCount ;
    //create expense line var DistExpense  = new DistExpenseLine (distCost ) ;
   DistExpense. createExpense (dept , deptAmount , distCost. name + "-" +
   distCost. distribution_rule. getDisplayValue ( ) ) ; }

Processing Distribution Costs

A scheduled job called Process FM Costs automatically processes distribution costs daily.