Add Jop Operation Record With BPM

When a maintenance job is created, we are trying to add a job operation to the job using a bpm upon creation. Does anyone have the code to add an operation record?

I did some experimenting with this. Check out this thread:
Add or Edit any Operation - My Custom Dashboards - ERP 10 - Epicor User Help Forum (epiusers.help)

You could probably do this with widgets. Invoke the BO methods below and use Fill Table by Query to set the fields on the new row.

As for code, this would work in a function:

//NOTE: jets is a JobEntryTableset
this.CallService<Erp.Contracts.JobEntrySvcContract>(svc =>
{
      //Adds new op at the end of the job. Needs Job and AssmblySeq
      svc.GetNewJobOper(ref jets, jobNum, assmblySeq);
      //Selects the new op you just created.
      Erp.Tablesets.JobOperRow newOp = jets.JobOper.Where(o => o.RowMod = "A")
      //Populate your new op with needed details.
      newOp.OpCode = "WHATEVS";
      newOp.EstSetHoursPerMch = 0.5;
      newOp.Machines = 1;
      newOp.ProdStandard = 2.5;
      newOp.StdFormat = "HR";
      //call update to push the updated job to the server.
      //Update will see the new Op and kindly pull in the OpDtl
      svc.Update(ref jets);

//The tricky part is marking the job as engineered/released.
//To do that, it only wants the header record from the Job.
      //First, create a emptyJobEntryTableset
      var relJets = new Erp.Tablesets.JobEntryTableset();
      //Then create a new empty JobHeadRow.
      var newRelRow = relJets.JobHead.NewRow();
      //Copy the real Job Header to the empty row you just made.
      BufferCopy.Copy(jets.JobHead[0], newRelRow);
      //Set the row as released and updated.
      newRelRow.JobReleased = true;
      newRelRow.RowMod = "U";
      //Add the now-populated row to the dummy tableset.
      relJets.JobHead.Add(newRelRow);
      //This changes other fields for you.
      svc.ChangeJobHeadJobReleased(ref relJets);
      //Call update again. 
      svc.Update(ref relJets);
}

You can do this straight from a BPM. The structure will be the same but the syntax will be a bit different. You can also, again, call these same methods from widgets in the same order, though BufferCopy.Copy() is a lot less work than filling by Query.

Note that this code has not been tested. It was cobbled together from a couple of other projects. It definitely hasn’t been tested on a maintenance job. So there might be some quirks specific to those that I didn’t account for.