Set ReadyToPrint to false when PO is approved

In Purchase Order Entry, Epicor automatically sets the ReadyToPrint checkbox to true when the PO is changed from unapproved to approved. I’m trying to prevent this from happening or atleast set the ReadyToPrint checkbox to false after it automatically changes to true.

To achieve this I’ve tried using a method directive on the PO.ChangeApproveSwitch method, both pre- and post-processing. I also tried it with a data directive on POHeader, both standard and intransaction. I’ve tried changing it in the ttPOHeader and also directly in the Db.POHeader.

After having no luck with the BPM approach i tried it in a customization of the PO Entry. After the Update method, which is the last method from the POAdapter that gets called when switching the Approve checkbox, I tried to set the ReadyToPrint field from the POHeader EpiDataView, with no luck either.

Am I missing something, or is Epicor overwriting the changes I make on the ReadyToPrint field?

Example code (Method directive - PO.ChangeApproveSwitch):

Execution after condition: ApproveValue variable is True

using (var txscope = IceDataContext.CreateDefaultTransactionScope()) 
{ 
    foreach (var ttPOHead in (from ttPOHead_Row in ttPOHeader
    where ttPOHead_Row.Company == Session.CompanyID
    select ttPOHead_Row))
    {
        foreach (var poHead in (from poHead_Row in Db.POHeader
        where poHead_Row.Company == ttPOHead.Company &&
              poHead_Row.PONum == ttPOHead.PONum
        select poHead_Row))
        {
            //this.PublishInfoMessage(poHead.ReadyToPrint.ToString(), Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
            //ttPOHead.RowMod = "U";
            ttPOHead.ReadyToPrint = false;
            poHead.ReadyToPrint = false;
        }
        
    }
    Db.Validate();
    txscope.Complete();
}

you might be running into a business object rule… I dont see anywhere that you are checking for the “Approved” state of the PO. I dont believe that you can mark it ready to print until POHead is marked as approved.
This BPM should not take any C# code. I would first try the widgets to set this in POHead.Update Method BPM as a PRE processing BPM, but only if the PO is approved.

I forgot to add that the code i gave as an example only executes after the condition is met that the ApproveValue variable is True.

Also i’ve tried using the standard Epicor widgets to set the field, but those didn’t work either.

Try using a POST on ChangedApproveSwitch. You may also want to use the Business Objects when doing this.

1 Like

did you try running a trace and doing it manually to find out what BOs are called?

1 Like