Production Activity Start/Stop via the Epicor REST API

I had a difficult time starting production activity via the REST API, hopefully I can save someone the same trouble with this brief overview of the general process I ended up with.


Notes

  • Your HTTP client must pass the callSettings header for most of the write (POST/PATCH) operations to succeed, refer to your instance’s Swagger docs to see how this is accomplished by checking the headers passed in the “Try it out” curl commands.
  • Clocking in/out employees is outside the scope of this overview, but an active clock is required for the given employee in order to start/stop production activity.
  • You’ll need your job number, activity type, and op codes: there are numerous ways to retrieve these, but that is outside the scope of this overview.
  • Co-parts, scrap and other related metadata is outside the scope of this overview, but once you are up and running with the core process you will have a solid idea about how to accomplish this.
  • Some endpoints return their dataset (ds) wrapped in a returnObj or parameters key, you will never pass the returnObj or parameters keys to another endpoint, the nested ds is all you need in these cases.
  • You can check for problems at almost any stage by calling the Erp.BO.LaborSvc/CheckWarnings endpoint with the dataset you intend to use in the next call. This can be especially useful if your implementation is surfacing Epicor’s errors directly.

Starting activity

1. Get employee activity

  • Purpose: Get current activity data for the employee, LaborHedSeq is primarily what we are after.
  • Endpoint: Erp.BO.LaborSvc/GetActiveLaborDtl
  • Input: employeeNum
  • Response: full dataset (wrapped in a returnObj key) of the employee’s activity, for now we only need the LaborHed.0.LaborHedSeq (I don’t know the circumstances where a LaborHed array might contain more than one item, if ever, so if defaulting to the first item is naive please let me know).

2. Get labor detail

  • Purpose: Retrieve the full labor header/detail payload for the retrieved LaborHedSeq.
  • Endpoint: Erp.BO.LaborSvc/GetByID
  • Input: laborHedSeq (obtained from step 1)
  • Response: full ds (dataset) payload representing the employee’s labor record.

3. Start the activity

  • Purpose: Get the full “start activity” dataset. Requires a start-type (e.g., ‘P’ for Production and ‘I’ for Indirect) and the retrieved labor dataset.
  • Endpoint: Erp.BO.LaborSvc/StartActivity
  • Payload:
{
  "LaborHedSeq": <laborHedSeq>,
  "StartType": <typeCode>,
  "ds": <employeeLaborDataset>
}
  • Response: ds representing the activity we’re starting.

4. Set the job number

  • Purpose: Assign the requested job number to the activity.
  • Endpoint: Erp.BO.LaborSvc/DefaultJobNum
  • Payload:
{
  "jobNum": <jobNum>,
  "ds": <activityDataset>
}
  • Response: updated ds with job details set.

5. Set the operation sequence

  • Purpose: Select the operation sequence to start within the job.
  • Endpoint: Erp.BO.LaborSvc/DefaultOprSeq
  • Payload:
{
  "oprSeq": <operationSequence>,
  "ds": <jobNumberDataset>
}
  • Response: updated ds with operation sequence details set.

6. Update the labor detail

  • Purpose: Persist the labor detail to finalize the activity start, time starts once this request succeeds.
  • Endpoint: Erp.BO.LaborSvc/Update
  • Input: the last dataset (from step 5), {"ds": <finalDataset>}
  • Response: final updated dataset, the activity is considered started.

Stopping activity

1. Retrieve the stop activity dataset

Note: You’ll need to know the laborHedSeq and laborDtlSeq of the labor you’re trying to stop, there are lots of ways to get this, in the context of a specific employee just get their active labor (Erp.BO.LaborSvc/GetActiveLaborDtl) and pick the relevant detail.

  • Purpose: Get the completed dataset we’ll then pass to the labor update endpoint to finalize the activity.
  • Endpoint: Erp.BO.LaborSvc/OnLoadEndActivity
    Payload:
{
  "iLaborHedSeq": <laborHedSeq>,
  "iLaborDtlSeq": <laborDtlSeq>
}
  • Response: The final dataset (wrapped in a returnObj key) to end the activity.

2. Update the labor detail

  • Purpose: Persist the labor detail to finalize the activity end, time stops once this request succeeds.
  • Endpoint: Erp.BO.LaborSvc/Update
    Input: the ds dataset from the returnObj of the previous call, just don’t pass the returnObj, you only need the ds.
  • Response: final updated dataset, the activity is considered ended.
4 Likes