---
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


---

# ExpenseLine - Global

# ExpenseLine - Global {#ariaid-title1}

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

The ExpenseLine script include is used by various cost management processes and can also be used for generating expense line (fm_expense_line) records from your own server-side
scripts.

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

## ExpenseLine - ExpenseLine (GlideRecord source, Number amount, String description) {#ariaid-title2}

Constructor for ExpenseLine object.
{#r_EL-ExpenseLine_GR_N_S__table_mlt_n4y_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| source | GlideRecord | GlideRecord identifying the source of the expense |
| amount | Number | Decimal number identifying the amount of the expense |
| description | String | (Optional) Description of the expense. |
[Table 1. Parameters]

{#r_EL-ExpenseLine_GR_N_S__table_mlt_n4y_kt} {#r_EL-ExpenseLine_GR_N_S__table_nlt_n4y_kt__entry__2}

| Type | Description |
|-|-|
| ExpenseLine object | The ExpenseLine object just instantiated. |
[Table 2. Returns]

{#r_EL-ExpenseLine_GR_N_S__table_nlt_n4y_kt}  

    //get some random CI to be used as an expense source
            var ci = new GlideRecord("cmdb_ci_server");
            ci.query();
            ci.next();
            
            //create expense line
            var exp = new ExpenseLine(ci, 234.56, "Test expense line");

## ExpenseLine - createExpense() {#ariaid-title3}

Creates a new expense line record.
{#r_EL-createExpense__table_rjs_jry_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#r_EL-createExpense__table_rjs_jry_kt} {#r_EL-createExpense__table_sjs_jry_kt__entry__2}

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

{#r_EL-createExpense__table_sjs_jry_kt}  

    //get some random CI to be used as an expense sourcevar ci =new GlideRecord("cmdb_ci_server");
    ci.query();
    ci.next();
     
    //create expense line
    var exp =new ExpenseLine(ci,234.56,"Test expense line");
    exp.setSummaryType("run_business");
    var success = exp.createExpense();

## ExpenseLine - processCIParents() {#ariaid-title4}

Used internally by the createExpense method to process CI
relationships when the expense source is a cmdb_ci record.
{#r_EL-processCIParents__table_wgx_mry_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#r_EL-processCIParents__table_wgx_mry_kt} {#r_EL-processCIParents__table_xgx_mry_kt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 6. Returns]

{#r_EL-processCIParents__table_xgx_mry_kt}

## ExpenseLine - setCostSource(GlideRecord costSource) {#ariaid-title5}

Identifies the source rate card or distribution cost that was the source of expense
line generation.
This is not the source (CI, task) of the expense.
{#r_EL-setCostSource_GR__table_hdb_xpy_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| costSource | GlideRecord | GlideRecord of CI rate card cost, distribution cost, or task rate card. This is generally only used for system-generated expense lines. |
[Table 7. Parameters]

{#r_EL-setCostSource_GR__table_hdb_xpy_kt} {#r_EL-setCostSource_GR__table_idb_xpy_kt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#r_EL-setCostSource_GR__table_idb_xpy_kt}

## ExpenseLine - setDescription(String description) {#ariaid-title6}

Defines the description of an expense.
{#r_EL-setDescription_S__table_zn5_4qy_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| description | String | Description of expense. |
[Table 9. Parameters]

{#r_EL-setDescription_S__table_zn5_4qy_kt} {#r_EL-setDescription_S__table_a45_4qy_kt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 10. Returns]

{#r_EL-setDescription_S__table_a45_4qy_kt}

## ExpenseLine - setParent(GlideRecord expense) {#ariaid-title7}

Sets the parent field on the expense line.
This is generally only used by the system
when generating indirect expenses such as business service aggregated expenses.
{#r_EL-setParent_GR__table_n4b_bry_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| expense | GlideRecord | Parent expense line record. |
[Table 11. Parameters]

{#r_EL-setParent_GR__table_n4b_bry_kt} {#r_EL-setParent_GR__table_o4b_bry_kt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 12. Returns]

{#r_EL-setParent_GR__table_o4b_bry_kt}

## ExpenseLine - setRecurring(Boolean recurring) {#ariaid-title8}

Flags the expense as recurring by setting the recurring field to true.
Expense lines are set to false by default so there is no need to call
setRecurring(false).
{#r_EL-setRecurring_B__table_nvl_5qy_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| recurring | Boolean | Set to true to identify expense line as a recurring expense. |
[Table 13. Parameters]

{#r_EL-setRecurring_B__table_nvl_5qy_kt} {#r_EL-setRecurring_B__table_ovl_5qy_kt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 14. Returns]

{#r_EL-setRecurring_B__table_ovl_5qy_kt}

## ExpenseLine - setSummaryType(String summaryType) {#ariaid-title9}

Sets a value for the expense line summary_type field.
{#r_EL-setSummaryType_S__table_zhx_gry_kt__entry__3}

| Name | Type | Description |
|-|-|-|
| summaryType | String | Typically you would set this to a value already specified in the expense line summary type field choice list. |
[Table 15. Parameters]

{#r_EL-setSummaryType_S__table_zhx_gry_kt} {#r_EL-setSummaryType_S__table_a3x_gry_kt__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 16. Returns]

{#r_EL-setSummaryType_S__table_a3x_gry_kt}  

    //get some random CI to be used as an expense sourcevar ci =new GlideRecord("cmdb_ci_server");
    ci.query();
    ci.next();
     
    //create expense line
    var exp =new ExpenseLine(ci,234.56,"Test expense line");
    exp.setSummaryType("run_business");


