7 Replies Latest reply on May 12, 2013 9:24 PM by Pranesh Mehta

    cancel hook on Purchase Order

    Pranesh Mehta Expert

      I have a requirement of adding a cancel hook such that it doesn't allow canceling a PR/PO on certain conditions, on adding a cancel hook on Requisition class, the hook fires only when you click on cancel button from the requisition but on clicking it from the Purchase Order the hook doesn't fire

       

      And the worst thing is a PR-V2 is created and thereby canceling both PO and PR.... Ariba Pdf's does say

      cancelHook A warning hook that is called when a user cancels a requisition. This hook is called only when the user cancels the requisition, and not when a user cancels an order.

       

      I tried adding cancelHook to the PurchaseOrder class properties but had no luck.

       

      But however is there anyway for me to have this hook fired irrespective of, from where the cancel is originated (PO/PR), if not I see this as a gap because this cancels a PR without firing the PR cancel hook.

       

      The only option we see right now is to add some conditions to the workflow events in wrf files, please let me know if there is any better way of doing this

        • Re: cancel hook on Purchase Order
          Majid Majid Apprentice

          Hi,

          If the requirement is not to allow cancelling a PR/PO on certain condition then you can also trying making the button in/visible.

           

          reg

          1 of 1 people found this helpful
            • Re: cancel hook on Purchase Order
              Pranesh Mehta Expert

              Hi Majid,

               

              Ya thts probably a better option.... if we dont find any other option we shall go for this, but tht would involve core code change i guess

                • Re: cancel hook on Purchase Order
                  Scott Corbett Master

                  You can hide the change/cancel buttons without a core hack.

                  To control the buttons from the Requisition screen you do this:

                  inClass ariba.purchasing.core.Requisition create an editability inField "LineItems". Your editability condition needs to extend ReqLineItemsEditable

                   

                  To control the buttons from the PO screen you do this:

                  inClass ariba.purchasing.core.PurchaseOrder create an editability inField "LineItems". Your editability condition needs to extend

                  ProcureItemsEditable.

                   

                  In either case you need to evaluate the "operation" which is part of the evaluate method. In your case, you'd operate on Cancel. (Note, you may want to stop Change such that the Change isn't deleting all the lines which turns into a Cancel. You could handle that through approval rules if you don't want to block Change)

                   

                  Here's a part of an example:

                   

                  public class ReqLineItemsEditability extends ReqLineItemsEditable

                  {

                   

                      public static final String cn = "ReqLineItemsEditability";

                      private static final String LICParam = "LineItemCollection";

                   

                      /** @param operation Type of operation being performed.

                      @param user      User performing the operation.

                      @param params    Parameters used to test the value.

                      @return true if the operation can be completed; otherwise false.

                       */

                   

                      // Note: this method controls the visibility of the Change/Cancel button

                      public boolean evaluate(int operation, User user, PropertyTable params)

                      {

                          Log.craprocure.debug("ReqLineItemsEditability.evaluate Is firing; operation = : " + operation);

                          String mn = cn + ".evaluate(): ";

                          if (params.getPropertyForKey(LICParam) == null || !(params.getPropertyForKey(LICParam) instanceof Requisition))

                              return false;

                         

                          Requisition req = (Requisition)params.getPropertyForKey(LICParam);

                         

                          if (operation == Cancel)

                          {

                                 //write your conditional logic and return a boolean value

                          }

                          else if (operation == Change)

                          {  

                                 //write your conditional logic and return a boolean value

              • Re: cancel hook on Purchase Order
                AribaMax Master

                Hi Pranesh,

                 

                I'm a bit late to this discussion...

                 

                I'm sure you would have found a solution by now. If not and if you would still want a solution by using cancelHook, you could customoze on the Approvable class itself instead of Requisition class (as Ariba has mentioned in the pdfs that cancelHook will only work when called from a Requisition and not from an Order).

                 

                inClass name="ariba.approvable.core.Approvable"

                 

                And then, on your custom Hook class, check the source object to be either Requisition, DirectOrder or PurchaseOrder, and if (and only if) so, perform your logic.

                 

                Hope it helps.

                1 of 1 people found this helpful
                • Re: cancel hook on Purchase Order
                  Amit Gupta Apprentice

                  Hi Pranesh,

                   

                  Just to continue with hiding cancel button, one more thought from my side.... a user needs a "Create Requisition" role to create a requisition which is mapped with "CancelPO" and "ChangePO" permissions. What about removing these permissions from "Create Requisition" role with which users won't be able to see cancel/change button on requisitions as well as on orders. This would be very quick without any custom or core code change.

                   

                  Amit