There are a number of reasons you might want to identify what Product is currently running on a line. For instance, if you are sending pitch details to L2L using the /api/1.0/record_details/
API, but don't have the productcode
, you can look it up.
Each of the following methods will return the Product ID. You can use the /api/1.0/productcomponents/
API to look up the product code, like this:
https://acme.leading2lean.com/api/1.0/productcomponents
/?auth=[auth]&site=[site]&id=[product id]
Method 1: Get it from the current pitch
If operators are manually selecting a product when they start a pitch, you can look up the actual_product using the /api/1.0/pitches/
API, like this:
https://acme.leading2lean.com/api/1.0/pitches/?auth=[auth]&site=[site]&line=[line id]&order_by=-pitch_start&pitch_start__lte=[timestamp]&pitch_end__gte=[timestamp]
You can then use the actual_product
property of the returned pitch to look up the product code.
Method 2: Get it from the Build Sequence
You can also get the current product straight from the Build Sequences API using the /api/1.0/buildsequences/get_current_order_on_line
method. This is the preferred method if you are using Product Orders. Here is a sample API call:
https://acme.leading2lean.com/api/1.0/buildsequence/get_current_order_on_line/?auth=[auth]&site=[site id]&linecode=[line code]
You can then use the product
property of the returned build sequence to look up the the product code.
Method 3: Look up the next Build Sequence
If there isn't a current order on the line, you can look up the next order using the /api/1.0/buildsequences/
API, like this:
https://acme.leading2lean.com/api/1.0/buildsequence/?auth=[auth]&linecode=[line code]&status__gte=2&status__lte=6&order_by=-schedule_start_date&limit=1
You can then use the product
property of the returned build sequence to look up the the product code.