This article will show how to query the L2L API for External Costs. External costs are also reported in many L2L reports.
Costs can be attributed to both Work Orders and Dispatches. It is important to understand the relationship between Work Order costs and Dispatch costs, since costs are frequently shared between the two.
Work Orders are essentially a planning tool in L2L. External costs can be added to a Work Order. Once a Dispatch is launched, all External Costs are linked to both the Work Order and the Dispatch.
The following APIs can be used to report Work Order and Dispatch External costs:
Dispatch External Costs
Objective: Retrieve all Dispatch external costs
Process Outline:
- Perform a search for Dispatches
POST https://[customer].leading2lean.com/api/1.0/dispatches/get_event_data/?auth=[api key]
- POST Parameters:
site=[site id]&lastupdated=[date]
- Optional POST Parameters:
limit=[limit]&areacode=[area code]&line_ids=[line ids]&dispatchtype_ids=[dispatch type ids]&externalid=[external id]&externalid_prefix=[external id prefix]&open=[open]&deleted=[deleted]
- See the official API documentation for full list of optional filters
- Pull out the Dispatches from the results that meet your criteria, and loop through the
external_costs
. - Sum all of the
cost
properties to calculate the cost of all external costs.
- POST Parameters:
Work Order External Costs
Objective: Retrieve all external costs from a Work Order
Process Outline:
- Retrieve a list of Work Order external costs
GET https://[customer].leading2lean.com/api/1.0/workorders/get_external_costs/[work order id]/
- Sum all of the
cost
properties to calculate the cost of all external costs