Updatable BAQ for PO Approval

I have a UBAQ that displays all PO’s pending approval due to buyer $ limit. My UFields are POApvMsg.MsgText and POApvMsg.ApproverResponse. The response field is setup with a dropdown list including the values ‘Approved’ and ‘Rejected’.

When executing the UBAQ, I can update the two fields with a comment and ‘Approved’ and then select to Update, but I receive the error “Approved amount cannot be less than PO Amount”.

When reviewing the PO Approval form, the ‘Approved Amount’ field is greyed out until the user selects Approved. However, the Approved Amount field is not a DB Field that I can easily update.

My thinking is that my UBAQ needs to recognize the ‘Approved’ change for the PO, and then somehow get the ApvAmt to match the POTotal, but how do I update the ApvAmt?

I’ve spent hours reviewing Epicor docs, EpiUsers, and other Google links, but I just haven’t found anything that brightened my brain bulb just yet, although I feel close. If anyone has any suggestions, example code, or links to tutorials I can work through for instances like these I would be immensely thankful.

You need to include the POHeader table in your query as the ApprovedAmount field is in that table

I did have this field in my query but I did not understand how to interact with it, or if it only updated after the PO Approver manually entered the approved amount on the PO Approval form. I just performed a little testing and may have a path forward.

In a separate UBAQ I only pulled in the POHeader and made the ApprovedAmount a UField. When I first attempted to manually update this field with the PO amount, it gave me error:
“Text: Purchase order 100720 is approved, Field(s) ApprovedAmount cannot be changed.”

The PO Approved checkbox is marked, but the Approval Status is Pending. I then went to the PO and manually unchecked the Approval box and saved. From there I went back to the UBAQ and successfully updated the ApprovedAmount to the PO amount.

Then when I went to my original UBAQ and ran it, the ApprovalStatus was now ‘Manually Unapproved’. I attempted to update/change the Ufield ApproverResponse to ‘Approved’ and received this message:

What’s odd is the query displays that the Approved Amount=PO Amount. I’m not sure why that message is coming back, but it kind of makes sense that the PO Approval has already processed.

I saw in another post around here about Erp.PO.ChangeApproveSwitch, so I think I will see if I can learn a little more about that and attempt some testing.

Hi
If you post your code/baq it will make it easier to help
Sue