Adding Approve/Reject Reasons

Acumatica ERP provides a robust approval workflow functionality for standard screens. Fortunately, developers have the ability to extend that valuable functionality to custom screens with some simple code and basic UI workflow configuration. In the most recent releases of Acumatica ERP, a new feature was added to allow prompting the approver to explain why they approved or rejected the document. While many developers have added approvals to custom screens, most may be unaware of how to add this new feature to prompt for a reason. The code samples here are based on Acumatica ERP 2021 R1.

Prerequisite: Knowledge of how to enable approval workflows for custom screen. While much of this will be covered here, the focus of this post is the approve/reject reason and not the approval engine itself.

First off, create (or open your existing) a graph extension for EPApprovalMapMaint. Two overrides are needed. The first, GetEntityTypeScreens, allows adding the new custom screen to the approval engine so that it is recognized in Approval (and Assignment) Maps. If the screen was setup for approvals already, this should be defined already. The Assignment maps are added similarly in EPAssignmentMapMaint, but that’s a story for another day. Note the 2 lines adding ZZ301000 and ZZ302000 to the “list”. These are the screen ID’s for the custom screens.

Second, specifically for the current topic – override EPRule_RowSelected. This event contains the logic to allow certain (screen) graphs to allow configuration in the Approval Map to prompt for Approved and/or Rejected reasons. Redefine isOfSupportedType, copying the list of currently enabled graphs and then adding the custom graphs. To reiterate, this will enable the OPTION of asking the user for a reason on approve or reject actions in the approval workflow engine when configuring the approval map.

After compiling, the approval map should allow enabling prompting for a reason. This can be “Not Required”, “Optional”, or “Required”. The (now) enabled setting is shown below in the Approval Map.

The final, and very important last coding step is to add the Smart Panel for the Reason Code prompt. This can be copied from the ASPX file of any screen currently supporting this feature. For convenience, see below for the code. This defines the Smart Panel and included controls for prompting the user. The approval workflow engine will handle when to ask and what to do with the response.

As a reminder, a screen using the approval workflow engine needs Approve and Reject actions as well as desired transitions in the new UI workflow inside the customization project. These are important to the approval process, but they require no special configuration to allow prompting for a reason on approve and/or reject. Below are samples of what to find in an existing screen with approvals to setup in your own screen. This can be done in code as well, but my sys admin handles this function currently, meaning it’s one less thing I have to do from development. 🙂

If adding approvals to the custom screen and not simply adding the prompt for approve/reject reason, remember to add the Approval Details tab and a tab on a preferences screen to enable the approval and define what maps should be used.

And here’s the end result on approve or reject, if configured…

Happy Coding!

1 thought on “Adding Approve/Reject Reasons”

Leave a Reply