Many businesses require that quotes be reviewed by management and/or engineers to ensure they fulfill a customers' needs and do not contain any mistakes. This approval workflow will address a slightly complex requirement which requires an approval based on certain criteria. The example business requirement is this:
- If a quote contains a configured product, then an engineer must approve it.
- If a quote's exceeds $100,000, then a sales manager must approve it.
- If a quote is rejected for any reason, it will be unsubmitted from the workflow.
- If a quote is accepted by all who needed to approve it, its state will be "Approved."
Step 1: OnSubmitted Logic
This requires some logic in the states. Let's start with the OnSubmitted event:
The first condition of the if checks if there are any products within the quote which are configured. If this is the case, then we will go to the engineer approval state, added in the states slot. If that is NOT the case, but the quote's total price exceeds $100,000, then the quote will go into the Manager Approval state. If neither are true, then the quote will automatically go into the Approved state by default.
Step 2: Engineer Approval
According to the prior logic, this state will only be applied if the quote contains any configured products. Note the "User Role: Engineer" block in the "By users and roles." Upon entry to this state, all users with this role will be sent a notification that this quote requires their approval. If an engineer approves the quote, it will apply the On approved logic which will check if it still needs to go through a manager approval due to its price exceeding $100,000. Otherwise, it will go to the Approved state. If the quote is rejected by the engineer, the quote will be returned to an "Unsubmitted" state, which returns it to the creator for corrections. The creator can then make whatever adjustments are necessary and resubmit the quote.
Step 3: Manager Approval
The Manager Approval state is just another Approval State block, with the user role of "Manager" added to the "users and roles" blocks. When it is approved, it has already gone through the engineer approval (if it needed it), so we can just move it to approved. If it is rejected, then it will be similarly unsubmitted from the workflow just like it would have if an engineer had rejected it.
Step 4: Approved State
The approved state is a simple state block which doesn't have any actions on it.
Further Logic: Rejection Reasons
Let's suppose the business has a new requirement: Managers should specify a reason for a quote's rejection, and depending on that reason, the quote should go to a different state rather than unsubmitted. Approval state blocks have the ability to specify rejection reasons to accommodate this.
In the above modified manager approval state, two rejection reasons have been added. Either it was rejected because it does not fulfill customer requirements or the customer had since cancelled the order. If the quote was rejected because it does not fulfill the customer requirements, then the quote should be unsubmitted, prompting the creator to make whatever adjustments are necessary. If the quote was rejected because the customer cancelled the order, however, then no adjustments are necessary and the quote should simply be placed into a new state called "Cancelled."
When a manager rejects a quote in this case, the button will provide options corresponding to each reason. The manager can select the reason for the rejection, which will then determine the quote's destination in the workflow.