---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# ExpenseAllocation - Global

# ExpenseAllocation - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The ExpenseAllocation script include 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.

This script include requires the Cost Management (com.snc.cost_management) plugin.

## ExpenseAllocation - ExpenseAllocation(GlideRecord expense, GlideRecord rule) {#ariaid-title2}

Called when you create a new ExpenseAllocation object.
This is not needed if scripting advanced allocation rules. This object is already available
as the <var class="keyword varname">allocation</var> variable.
{#r_EA-ExpenseAllocation_GR_GR__table_dby_yqd_lt__entry__3}

| 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 1. Parameters]

{#r_EA-ExpenseAllocation_GR_GR__table_dby_yqd_lt} {#r_EA-ExpenseAllocation_GR_GR__table_eby_yqd_lt__entry__2}

| Type | Description |
|-|-|
| ExpenseAllocation object | The ExpenseAllocation object just created. |
[Table 2. Returns]

{#r_EA-ExpenseAllocation_GR_GR__table_eby_yqd_lt}  

    var allocation=new ExpenseAllocation(expenseGlideRecord, ruleGlideRecord);

## ExpenseAllocation - createAllocation(GlideRecord target, Number amount) {#ariaid-title3}

Creates an expense allocation (fm_expense_allocation) record
referencing the parameters provided during instantiation and this method.
{#r_EA-createAllocation_GR_N__table_afg_prd_lt__entry__3}

| 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 3. Parameters]

{#r_EA-createAllocation_GR_N__table_afg_prd_lt} {#r_EA-createAllocation_GR_N__table_bfg_prd_lt__entry__2}

| Type | Description |
|-|-|
| Boolean | True if the expense allocation was successfully created. |
[Table 4. Returns]

{#r_EA-createAllocation_GR_N__table_bfg_prd_lt}  

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


