Stuck on how to cycle through Mtl for Job

Good Afternoon All,

Here is my Goal: Update Mtl costs in job when Released
Further definition of Updated cost is — Should be Std Cost

What I have achieved so far is on the Method JobEntry.ChangeJobHeadJobReleased to capture when the Release checkbox is checked ( yes) .

I am able to retrieve the Job Number ( row ?? ) that is RowMod = “U”.

Where I am stuck is to cycle through the Materials . Once I am there I can ( I Believe I can…) check if the EstUnit cost = Std cost for that material. If not, change Est unit cost to Std Cost.

I have tried this on a Data Directive but can only capture if a Mtl row has actually changed.

Here is the Code I have so far…


int c = 0;  // counter

decimal stdCost = 0; // Std Cost of Mtl
decimal estCost = 0; // Est Cost of Mtl

foreach(var  dset in ds.JobHead.Where(dset => dset.Company == callContextClient.CurrentCompany 
                                             && dset.RowMod == "U"
                                             && dset.JobReleased == true))

{
      c = c + 1;
       Epicor.Customization.Bpm.InfoMessage.Publish
       ("Pre Process RowMod = " + dset.RowMod  + "\n"
       + "Released = " + dset.JobReleased) ;
     
          foreach(var mtl in ds.JobMtl)
          {
             Epicor.Customization.Bpm.InfoMessage.Publish
             ("PN = " + mtl.PartNum);
             // code to check and update here///
          }
}

Epicor.Customization.Bpm.InfoMessage.Publish
       ("c = " + c.ToString() ) ;

This is related to another post I did regarding Job Costs and DMT updated costs. Halfway thinking this approach could work via DMT just un-releasing, re-releasing jobs

All thoughts and input are appreciated. Trying to get this going before Ya’ll head to Insights. I cant go this year … :cowboy_hat_face: :frowning_face:

Dean

self update…

Wound up using fill table by Query collecting the Materials from JobMtl. Filled 2 whole datasets, dsOldCosts and dsNew Costs. I am guessing it may not be the most efficient but I am slowly making progress…

Working on comparing the 2…

Dean

1 Like

IMO - good move, my initial thought when reading your post was to ditch the code and use the widgets in the BPM to query for each material’s part costs and call the update method. Haven’t done this, but you being Public Cloud the widgets are the best way… IMO.

Thank you Rick,

I have used code blocks before, with the change to Datasets away from TempTables, It feels like the syntax/structure has changed. That’s what I was struggling with initially. I created 2 datasets, 1 filling the ds.JobMtl from the ERP.JobMtlTable and the 2nd from the same table with a join to ERP.PartCost to get the costs( binding StdMtlCost+ StdLaborCost etc) to the EstUnit cost of the dataset. I then used a codeblock to loop through the 1st ds,JobMtl and look for the same MtlPart in the 2nd ds and compare the EstUnitCost. aal goes well from there.

When trying to use the code originally posted, it was like the dsJobMtl was empty…

Dean