{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":991,"path":"api-reference/server-api-reference/c_ExpenseAllocationAPI.md","title":"ExpenseAllocation - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# ExpenseAllocation- Global\n\nThe 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.\n\nThis script include requires the Cost Management \\(com.snc.cost\\_management\\) plugin.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## ExpenseAllocation - ExpenseAllocation\\(GlideRecord expense, GlideRecord rule\\)\n\nCalled when you create a new ExpenseAllocation object.\n\nThis is not needed if scripting advanced allocation rules. This object is already available as the *allocation* variable.\n\n|Name|Type|Description|\n|----|----|-----------|\n|expense|GlideRecord|GlideRecord identifying the source of the expense.|\n|rule|GlideRecord|GlideRecord identifying the rule to use in allocating the expense line.|\n\n|Type|Description|\n|----|-----------|\n|ExpenseAllocation object|The ExpenseAllocation object just created.|\n\n```\nvar allocation=new ExpenseAllocation(expenseGlideRecord, ruleGlideRecord);\n```\n\n## ExpenseAllocation - createAllocation\\(GlideRecord target, Number amount\\)\n\nCreates an expense allocation \\(fm\\_expense\\_allocation\\) record referencing the parameters provided during instantiation and this method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|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.|\n|amount|Number|The amount of the allocation.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the expense allocation was successfully created.|\n\n```\nvar allocation=new ExpenseAllocation(expenseGlideRecord, ruleGlideRecord);\nallocation.createAllocation(costCenterGlideRecord, 2345.67);\n```\n\n"}}