{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":992,"path":"api-reference/server-api-reference/c_ExpenseLineAPI.md","title":"ExpenseLine - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# ExpenseLine- Global\n\nThe 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.\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## ExpenseLine - ExpenseLine \\(GlideRecord source, Number amount, String description\\)\n\nConstructor for ExpenseLine object.\n\n|Name|Type|Description|\n|----|----|-----------|\n|source|GlideRecord|GlideRecord identifying the source of the expense|\n|amount|Number|Decimal number identifying the amount of the expense|\n|description|String|\\(Optional\\) Description of the expense.|\n\n|Type|Description|\n|----|-----------|\n|ExpenseLine object|The ExpenseLine object just instantiated.|\n\n```\n//get some random CI to be used as an expense source\n        var ci = new GlideRecord(\"cmdb_ci_server\");\n        ci.query();\n        ci.next();\n        \n        //create expense line\n        var exp = new ExpenseLine(ci, 234.56, \"Test expense line\");\n```\n\n## ExpenseLine - createExpense\\(\\)\n\nCreates a new expense line record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the expense line was successfully created.|\n\n```\n//get some random CI to be used as an expense sourcevar ci =new GlideRecord(\"cmdb_ci_server\");\nci.query();\nci.next();\n \n//create expense line\nvar exp =new ExpenseLine(ci,234.56,\"Test expense line\");\nexp.setSummaryType(\"run_business\");\nvar success = exp.createExpense();\n\n```\n\n## ExpenseLine - processCIParents\\(\\)\n\nUsed internally by the createExpense method to process CI relationships when the expense source is a cmdb\\_ci record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## ExpenseLine - setCostSource\\(GlideRecord costSource\\)\n\nIdentifies the source rate card or distribution cost that was the source of expense line generation.\n\nThis is not the source \\(CI, task\\) of the expense.\n\n|Name|Type|Description|\n|----|----|-----------|\n|costSource|GlideRecord|GlideRecord of CI rate card cost, distribution cost, or task rate card. This is generally only used for system-generated expense lines.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## ExpenseLine - setDescription\\(String description\\)\n\nDefines the description of an expense.\n\n|Name|Type|Description|\n|----|----|-----------|\n|description|String|Description of expense.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## ExpenseLine - setParent\\(GlideRecord expense\\)\n\nSets the parent field on the expense line.\n\nThis is generally only used by the system when generating indirect expenses such as business service aggregated expenses.\n\n|Name|Type|Description|\n|----|----|-----------|\n|expense|GlideRecord|Parent expense line record.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## ExpenseLine - setRecurring\\(Boolean recurring\\)\n\nFlags the expense as recurring by setting the recurring field to true.\n\nExpense lines are set to false by default so there is no need to call setRecurring\\(false\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|recurring|Boolean|Set to true to identify expense line as a recurring expense.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## ExpenseLine - setSummaryType\\(String summaryType\\)\n\nSets a value for the expense line summary\\_type field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|summaryType|String|Typically you would set this to a value already specified in the expense line summary type field choice list.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\n//get some random CI to be used as an expense sourcevar ci =new GlideRecord(\"cmdb_ci_server\");\nci.query();\nci.next();\n \n//create expense line\nvar exp =new ExpenseLine(ci,234.56,\"Test expense line\");\nexp.setSummaryType(\"run_business\");\n```\n\n"}}