The ExpenseAllocation API is included with the Cost Management Plugin as a script include record. It is used by various cost management processes and can also be used for generating custom expense allocation records (fm_expense_allocation) from scripted expense allocation rules.

ExpenseAllocation - createAllocation(GlideRecord target, Number amount)

Creates an expense allocation (fm_expense_allocation) record referencing the parameters provided during instantiation and this method.

Table 1. Parameters
Name Type Description
target GlideRecord GlideRecord target of the allocation, for example a cost center record to allocate an expense to Decimal amount - the amount of the allocation.
amount Number The amount of the allocation.
Table 2. Returns
Type Description
Boolean True if the expense allocation was successfully created.

Example

var allocation=new ExpenseAllocation(expenseGlideRecord, ruleGlideRecord);
allocation.createAllocation(costCenterGlideRecord, 2345.67);

ExpenseAllocation - ExpenseAllocation(GlideRecord expense, GlideRecord rule)

Called when you create a new ExpenseAllocation object.

This is not needed if scripting advanced allocation rules. This object is already available as the allocation variable.

Table 3. Parameters
Name Type Description
expense GlideRecord GlideRecord identifying the source of the expense.
rule GlideRecord GlideRecord identifying the rule to use in allocating the expense line.
Table 4. Returns
Type Description
ExpenseAllocation object The ExpenseAllocation object just created.

Example

var allocation=new ExpenseAllocation(expenseGlideRecord, ruleGlideRecord);