Toggle PO Approval from BPM

Hey everyone,

I have a Pre-Processing BPM on an Updatable BAQ. Ultimately trying to adjust RO releases, but to even get there I have to change a PO from approved to unapproved. To test this, I’m invoking the following:

BO Method Erp.PO.GetByID passing an integer to test (200021) and have created a variable of type POTableset as the return.

Then, I’m invoking BO Method Erp.PO.ChangeApproveSwitch passing false to ApproveValue, [ignore] to ViolationMsg and passing the POTableset variable returned from the GetByID method.

When the BPM executes it throws the error message: POHeader is not available

I’ve tried both using custom c# code and using the widget Invoke PO Method, both producing the same error message.

Anyone have any thoughts? I’ve ran these two actions through the tracelogs and the only difference I see in the tracelogs is that the GetByID returntype is Erp.Tablesets.POTableset and the ChangeApproveSwitch is trying to pass a parameter of Erp.BO.PODataset.

I’m on version 10.2.100.7 of Epicor. Thanks in advance for any assistance!

EDIT: here is the custom code that is producing the same results

var POApproveSwitchDataSet = new Erp.Tablesets.POTableset();
Erp.Contracts.POSvcContract hPOApproveHandle = null;
if (hPOApproveHandle == null) {
  hPOApproveHandle = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.POSvcContract>(Db);
} 

POApproveSwitchDataSet = hPOApproveHandle.GetByID(PONumCheck);
      
if (POApproveSwitchDataSet != null) {
	hPOApproveHandle.ChangeApproveSwitch(false,out ViolationMsg, ref POApproveSwitchDataSet);
}

Get by id not returning expected results?

If you get record, set the RowMod = “U”

Thank you @Chris_Conn, that did get me past the error. I updated the POHeader object inside the Dataset the following way:

POApproveSwitchDataSet.POHeader[0].RowMod=&quot;U&quot;;

Setting that and then invoking the CheckBeforeUpdate method and Update method I was able to see my change reflected. Thank you again for your help.

1 Like

Hi,

im trying to also approve POs from BPM but always getting the error: “You must Accept or Reject the PO.”. Can you please see what I may doing wrong (im not sure of the parameters for CheckBeforeUpdate()? Thanks

var POApproveSwitchDataSet = new Erp.Tablesets.POTableset();
    Erp.Contracts.POSvcContract hPOApproveHandle = null;
    if (hPOApproveHandle == null) 
    {
      hPOApproveHandle = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.POSvcContract>(Db);
    } 
    
    POApproveSwitchDataSet = hPOApproveHandle.GetByID(ttPOApvMsg.FirstOrDefault().PONum);
          
    if (POApproveSwitchDataSet != null) 
    {
      
      POApproveSwitchDataSet.POHeader[0].RowMod="U";
      
      hPOApproveHandle.ChangeApproveSwitch(true,out ViolationMsg, ref POApproveSwitchDataSet);
      
      hPOApproveHandle.CheckBeforeUpdate(out str1, out str2, out str3, "", POApproveSwitchDataSet);
      hPOApproveHandle.Update(ref POApproveSwitchDataSet);