Once an order is placed that requires approval, an e-mail is sent to the person who approves that buyer’s orders. Also, the order is displayed on the approver’s approvals page, user/approvals.jsp. Clicking any order in that list takes him to a screen where he can reject or approve the order.

Approvers can see the orders that are to be approved on the Motorprise home page and also from the My Account section by clicking the Approval Requests link (user/). The following is the relevant JSP code in approvals.jsp that displays the pending approval requests.

<%/* Pass profile id and state values to ApprovalRequiredDroplet to get all
   the orders*/%>

<dsp:droplet name="ApprovalRequiredDroplet">
   <dsp:param bean="Profile.id" name="approverid"/>
   <dsp:param name="state" value="open"/>
   <dsp:param name="startIndex" param="startIndex"/>
   <dsp:oparam name="output">

      <tr valign=top>
         <td width=33%><span class="small"><b>Order #</b></span></td>
         <td width=33%><span class="small"><b>Date ordered</b></span></td>
         <td width=33%><span class="small"><b>Status</b></span></td>
      </tr>
      <tr>
         <td colspan=3><hr size=1 color="#666666"></td>
      </tr>
      <%/* Iterate through each order and display order info */%>

      <dsp:droplet name="ForEach">
         <dsp:param name="array" param="result"/>
         <dsp:oparam name="output">
      <tr>
         <td><dsp:a href="order_pending_approval.jsp">
            <dsp:param name="orderId" param="element.id"/>
            <dsp:valueof param="element.id"/></dsp:a>
         </td>
         <td><dsp:valueof date="MMMMM d, yyyy"
            param="element.submittedDate"/></td>
         <td><dsp:valueof param="element.state"/></td>
      </tr>
   </dsp:oparam>
   <dsp:oparam name="outputEnd">

We used the ApprovalRequiredDroplet to get the orders with pending approvals for the given approverid. Because we want the orders that are pending, we pass the value open to the state parameter to fetch the orders. The ApprovalRequiredDroplet returns an array of orders in the result parameter, on which we iterate using a ForEach droplet getting the individual orders and providing a link to access each order.

On the approvals page, the approver can click on the order number that takes him or her to order_pending_approval.jsp, which displays the order information and options to approve or reject the order.

If the approver chooses the Approve Order link, he or she is taken to approve_order.jsp to optionally enter a message for the user that will appear on the order and to approve the order and submit it to be fulfilled. The following is the relevant JSP code in approve_order.jsp:

<%/* Set the order id of of approvalformahandler to the order to be approved and
   provide submit buttons for approve/cancel. */%>
<dsp:form action="approvals.jsp" method="post">
   <dsp:input bean="ApprovalFormHandler.orderId" paramvalue="orderId"
      type="hidden"/>
   <span class=help>Enter a message.</span><br>
   <dsp:textarea bean="ApprovalFormHandler.approverMessage" rows="7"
      cols="50"></dsp:textarea><p>
   <%/* page to be redirected if the order approval is successful */%>
   <dsp:input bean="ApprovalFormHandler.approveOrderSuccessURL" type="hidden"
      value="approve_confirm.jsp"/>
   <%/* page to be redirected if the order approval fails */%>
   <dsp:input bean="ApprovalFormHandler.approveOrderErrorURL" type="hidden"
      value="approve_order.jsp"/>
   <dsp:input bean="ApprovalFormHandler.approveOrder" type="submit" value="Approve
      order"/> &nbsp;
   <input type="submit" value="Cancel"> &nbsp;
</dsp:form>

If the approver clicks the Reject Order link, he or she is taken to reject_order.jsp to optionally enter a message for the user and to reject the order. The following is the relevant JSP code in reject_order.jsp to display this:

<dsp:form action="order_pending_approval.jsp" method="post">
   <dsp:input bean="ApprovalFormHandler.orderId" paramvalue="orderId"
      type="hidden"/>
   <span class=help>Enter a message.</span><br>
   <dsp:textarea bean="ApprovalFormHandler.approverMessage" rows="7"
      cols="50"></dsp:textarea><p>
   <input name="orderId" type="hidden" value="<dsp:valueof param="orderId"/>">
   <dsp:input bean="ApprovalFormHandler.rejectOrderSuccessURL" type="hidden"
      value="reject_confirm.jsp"/>
   <dsp:input bean="ApprovalFormHandler.rejectOrderErrorURL" type="hidden"
      value="reject_order.jsp"/>
   <dsp:input bean="ApprovalFormHandler.rejectOrder" type="submit" value=
      "Reject order"/> &nbsp;
   <input type="submit" value="Cancel"> &nbsp;
</dsp:form>

When the approver approves or rejects the order, an e-mail is sent to the buyer updating him of that order’s status. The buyer also can see the status of his orders in the My Account section on the Open Orders page, en/user/orders_open.jsp.

Whenever order is approved or rejected, the Approval Update event is fired with the approvalStatus property of the message set to approved or rejected. In order to send an e-mail when the order is approved or rejected, we created a scenario, ApprovalNotification, that listens to this event and, depending on the approvalStatus, sends an approved or rejected e-mail to the customer. (For more information on the ApprovalNotification, see the Merchandising chapter in this guide.)

When the order is approved, it is automatically submitted and the status of the order displays as “submitted” in the buyer’s order history. In the approver’s My Account section, the order is moved to the “approved orders” view. If the order is rejected, the order will not be submitted and appears in the buyer’s order history with the status “rejected.”

You can create similar approval conditions and plug them into the checkRequiresApproval pipeline chain in the same way.

For more information on the approval process, see the Core Commerce Programming Guide.


Copyright © 1997, 2019 Oracle and/or its affiliates. All rights reserved. Legal Notices