Monday, January 26, 2015

How to Link an Alert with a simple Workflow to send notifications

Salam Alaikum,

   There is a needed requirement in many projects for the users to get notified once a business event occurs. And that can be easily covered by an Alert, if the business is for the users to receive emails once the event happens, explaining the event and providing needed information about it to the users.

   But another popular requirement is for the user to receive notifications via a workflow (Worklist notifications).

   It can be done easily using an Alert along with a simple Workflow. And here is how....

   First Step:
   Create a simple Workflow like the one shown in the screenshot below.
(the workflow should at least have one process, one notification , one message and two attributes)

   The workflow should have the attributes (P_NOTE_TITLE,XX_MESSAGE_BODY - both are the internal names of the attributes) to fill the notification with the business case information that the user will receive.

   And of course, you have to save the workflow on the database.

   Second Step:
   We should create the alert that should trigger once the business event occurs.

Please note that the alert select statement should include the subject of the notification and notification body (message) you want to be sent to the users.

Third Step:
In the created Alert you should create an action of type SQL statement script that calls the procedure that runs the workflow created in first step.

And the script should be a call to a function on the database that start the workflow process.

execute XX_SIMPLE_NOTIFICATION.XX_SEND_MULTI_NOTES (   'send Not'  , '&p_message'  ,  '&p_title' );

And on the database level, the procedure should look like this:

 procedure  XX_SEND_MULTI_NOTES (     P_action_name varchar2 ,
                                       P_MESSAGE varchar2  ,
                                       P_TITLE varchar2 )

    wf_engine.CreateProcess(itemtype => 'XXZNOTE',
                            itemkey  => 'SIMPLE_NTF' || V_SEQ,
                            process  => 'SEND_TO_WAREHOUSE_TEAM');

    wf_engine.SetItemAttrTEXT(itemtype => 'XXZNOTE',
                              itemkey  => 'SIMPLE_NTF' || V_SEQ,
                              aname    => 'XX_MESSAGE_BODY',
                              avalue   =>  replace(P_MESSAGE,'@',chr(10)));

    wf_engine.SetItemAttrTEXT(itemtype => 'XXZNOTE',
                              itemkey  => 'SIMPLE_NTF' || V_SEQ,
                              aname    => 'ACTION_NAME',
                              avalue   => P_action_name);

    wf_engine.SetItemAttrTEXT(itemtype => 'XXZNOTE',
                              itemkey  => 'SIMPLE_NTF' || V_SEQ,
                              aname    => 'P_NPTE_TITLE',
                              avalue   => P_TITLE);

    wf_engine.StartProcess(itemtype => 'XXZNOTE',
                           itemkey  => 'SIMPLE_NTF' || V_SEQ);

   And each time the alert gets triggered a notification should be sent to the predefined user that for example in a different attribute with constant value.

   Hope you found it useful guys, feel free to leave a comment if have any note on the subject.        

1 comment:

  1. Regards
    Sridevi Koduru (Senior Oracle Apps Trainer
    LinkedIn profile -
    Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at | +91 - 9581017828.