Inspection Processing - Using within BPM Code Block

,

I’m attempting to automate inspection processing for a specific use case we need in receipts. I’ve ran a trace and found the “InspectReceipt” function. I’ve successfully gotten the function to process an inspection, but the PO that is waiting for the inspection to finish does not get it’s “PassedQty” updated and stays in the “Inspection” status.

Here is the code in question. It’s on a Standard Data Directive on RcvDtl:

foreach (var rcv in ttRcvDtl.Where(dtl => dtl.RowMod != "" && dtl.RowMod != "D" && dtl.PONum != 0))
   {
      //...
          //do auto inspection
          string msg = "";
          var insp = ServiceRenderer.GetService <Erp.Contracts.InspProcessingSvcContract>(Db);
          Erp.Tablesets.InspProcessingTableset inspTs = new Erp.Tablesets.InspProcessingTableset();
          //get inspection for receipt
          inspTs = insp.GetReceiptByID(rcv.VendorNum, "", rcv.PackSlip, rcv.PackLine);
          inspTs.InspRcpt[0].InspectorID = "AUTO";
          inspTs.InspRcpt[0].InspectedBy = "AUTO";
          inspTs.InspRcpt[0].InspectorIDName = "AUTO";
          inspTs.InspRcpt[0].PassedQty = rcv.OurQty;         
          inspTs.InspRcpt[0].Done = true;
          inspTs.InspRcpt[0].RowMod = "U";
          string legalNumMsg = "";
          int iDMRNum = 0;
          int iNonConfID = 0;
          insp.InspectReceipt(out legalNumMsg, out iDMRNum, out iNonConfID, ref inspTs);
   }

Using the GetReceiptByID, editing the fields, and using InspectReceipt the same way in the BL Test tool has the expected results of the PO line closing since inspection has been completed.

Here’s some screen shots of the result of the code inspection:
NonConf Table:

PO Status:
image
image

PORel Table:

Any help/direction of why the PO does not update right would be appreciated. Thanks!

Are you sure your foreach enumerable has any elements?

Yup, it hits the code block fine and goes through the InspectReceipt function. Only thing not being updated is the PO’s passed qty. When using the InspectReceipt function on the BL tester it does update the PO, so unsure why it doesn’t within the bpm.

You might need to call OnChangePassedQty before updating the other fields and calling InspectReceipt. Or maybe do what you’re doing and then call OnChangePassedQty afterward. The name starting with “On” suggests that this method gets called automatically when PassedQty changes, but the docs say (emphasis added):

This method should be run when the PassedQty field changes.

I don’t remember the specifics off the top of my head, but I feel like I’ve run into situations with other BOs where certain fields can’t be updated directly.

I had attempted that before. In the Trace it’s called before the inspection is saved. We’ve ended up using an external program to call the function via Rest. We suspect it might be a timing issue when trying to use it in the bpm.

Thanks for you help!

1 Like