How to Close Approval or Response Required based Notifications from backend?

Earlier we have seen how to close FYI based notification. Here in this article lets see how to close Approval/Response based notification from backend.

Since its Approval/Response based notification, first we need to set the Response RESULT value using API wf_notification.setattrtext and then close notification by responding to it using API wf_notification.respond.

Syntax

--
--Setting 'RESULT' value
--
   wf_notification.setattrtext
                 (nid    => p_notification_id,
                  aname  => 'RESULT',
                  avalue => p_result_value);
--
--Responding to the Notification
--
wf_notification.respond
                 (nid             => p_notification_id,
                  respond_comment => 'RESULT',
                  responder       => p_result_value);

Example

BEGIN
--
--Setting 'RESULT' value
--
   wf_notification.setattrtext (nid         => '4754620', --Notification ID
                                aname       => 'RESULT', --This is a constant value, will always be same
                                avalue      => 'APPROVED' --This value can be anything, depends on your workflow
                               );
--
--Responding to the Notification
--
   wf_notification.respond (nid             => '4754620', --Notification ID
                            respond_comment =>  'Approved From backend', --This can be any user comment
                            responder       =>  'STHALLAM' --user name who responds
                           );
   COMMIT;
END;

Points to Note:

  1. aname will always be ‘RESULT
  2. avalue can be anything depending upon the Action resultant value configured in the workflow definition