Friday 21 April 2017

How to make Reject comments mandatory in oracle workflow

Use Below Code

PROCEDURE btvl_reject_commnet_mandate (
      p_item_type   IN              VARCHAR2,
      p_item_key    IN              VARCHAR2,
      actid         IN              VARCHAR2,
      funmode       IN              VARCHAR2,
      resultout     OUT NOCOPY      VARCHAR2
   )
   IS
      v_response         VARCHAR2 (2000);
      l_user_comment     VARCHAR2 (2000);
      approval_comment   EXCEPTION;
   BEGIN
/*===================================================================================
This will derive the button by looking at the response from the notification. the WF_ENGINE.CONTEXT_NID variable will tell you the notification ID that is being responded to, and we can derive the response from there.
====================================================================================*/
      v_response :=
                wf_notification.getattrtext (wf_engine.context_nid, 'RESULT');
/*===================================================================================
This will retrieve the value which is stored in the Approval Comments field by the approver when the reject button is pressed.
====================================================================================*/
      l_user_comment :=
         wf_notification.getattrtext (wf_engine.context_nid,
                                      'COMMENTS'
                                     );

/*===================================================================================
This block will be fired when the user has pressed the 'Reject' Button and the comments is null and then it will raise the user defined error. And the workflow will not continue untill the user enters value in the comments field for rejection.
===================================================================================*/
      BEGIN
         IF (    funmode = 'RESPOND'
             AND v_response = 'REJECTED'
             AND l_user_comment IS NULL
            )
         THEN
            RAISE approval_comment;
         END IF;
      EXCEPTION
         WHEN approval_comment
         THEN
            raise_application_error
               (-20010,
                'Approval Comment Field cannot be Null. Please enter reason for rejection and click reject.'
               );
            RAISE;
      END;
   END;

After compiling above procedure then call this procedure to notification 





5 comments:

  1. Nature always helps a writer to learn from its elements. Nature always try to teach new lessons and a writer transform its experience into words. He can transform even silence into words. This blog taught me a lesson.
    receipt maker

    ReplyDelete

  2. My spouse and I love your blog and find almost all of your posts to be just what I’m looking for. Appreciating the persistence you put into your blog and the detailed information you provide. I found another one blog like you Oracle Cloud Infrastructure .Actually I was looking for the same information on internet for Oracle Cloud Infrastructure and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete
  3. I was surfing net and fortunately came across this site and found very interesting stuff here. Its really fun to read. I enjoyed a lot. Thanks for sharing this wonderful information. best spy apps

    ReplyDelete
  4. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! spy phone app

    ReplyDelete
  5. Albert Strong has a long and distinguished career as a Management Consultant and Senior Project Manager. His work has included the successful management soc 2 report

    ReplyDelete

AOL SYLLABUS: PREREQUISITE SQL PL/SQL D2K GENERAL INTRODUCTION KNOW HOW OF ERP Version of Oracle Apps 11i Comparison of 10.7/11...