Saturday, 24 May 2014

How to send attachment in oracle workflow notification / blob documents as attachment in oracle workflow notification



Create normal workflow process with simple notification as below.





Create a new document type attribute with below details.





drag and drop this attribute under "Attachment_notification"(notification message). Set the Attributes property as shown below.





Your workflow is complete. Now write the following PL/SQL code and run the workflow to get the notification. 


Sequence for item key :::

create sequence xx_example_s
start with 1
increment by 1;




CREATE OR REPLACE PACKAGE xx_example
IS
   PROCEDURE xx_training_wf;

   PROCEDURE xx_attach_p (
      document_id     IN       VARCHAR2,
      display_type    IN       VARCHAR2,
      document        IN OUT   BLOB,
      document_type   IN OUT   VARCHAR2
   );
END;

CREATE OR REPLACE PACKAGE BODY xx_example
IS
   gv_document_id   VARCHAR2 (100) := '2955797';

   PROCEDURE xx_training_wf
   IS
      l_itemtype   VARCHAR2 (30)  := 'XXTEST';
      l_itemkey    VARCHAR2 (300);
   ---l_file_name   VARCHAR2 (100) := 'holidaylist.xls';
   --l_unique_id   VARCHAR2 (50)  := unique_id;
   BEGIN
      SELECT TO_CHAR (xx_example_s.NEXTVAL)
        INTO l_itemkey
        FROM DUAL;

      wf_engine.createprocess (l_itemtype, l_itemkey, 'XX_TEST_ATTACHMENT');
      wf_engine.setitemattrdocument
                         (itemtype        => l_itemtype,
                          itemkey         => l_itemkey,
                          aname           => 'XX_ATT1',
                          documentid      =>    'PLSQLBLOB:XX_EXAMPLE.XX_ATTACH_P/'
                                             || gv_document_id
                         );
      wf_engine.setitemattrtext (itemtype      => l_itemtype,
                                 itemkey       => l_itemkey,
                                 aname         => '#FROM_ROLE',
                                 avalue        => 'WF_EMP1'
                                );
      wf_engine.setitemattrtext (itemtype      => l_itemtype,
                                 itemkey       => l_itemkey,
                                 aname         => 'XXTIMEOUT',
                                 avalue        => 2880
                                );
      wf_engine.startprocess (l_itemtype, l_itemkey);
      COMMIT;
   END xx_training_wf;

   PROCEDURE xx_attach_p (
      document_id     IN       VARCHAR2,
      display_type    IN       VARCHAR2,
      document        IN OUT   BLOB,
      document_type   IN OUT   VARCHAR2
   )
   IS
      lv_file_name           VARCHAR2 (100) := NULL;
      lv_file_content_type   VARCHAR2 (100) := NULL;
      ld_document            BLOB;
   BEGIN
      SELECT file_name, file_content_type, file_data
        INTO lv_file_name, lv_file_content_type, ld_document
        FROM fnd_lobs
       WHERE file_id = 2955797;

      document_type := lv_file_content_type || ';name=' || lv_file_name;
      DBMS_LOB.COPY (document, ld_document, DBMS_LOB.getlength (ld_document));
      COMMIT;
   EXCEPTION
      WHEN OTHERS
      THEN
         wf_core.CONTEXT ('xx_example',
                          'xx_attach_p',
                          'document_id',
                          'display_type'
                         );
         RAISE;
   END xx_attach_p;
END xx_example;



====================================================

Now execute procedure  to initiate the workflow.

execute xx_example.xx_training_wf ;

====================================================

Attachment will look like this










3 comments:

  1. Hi, I am following the step. I managed to get the attachment in email notification but i can't see the attachment link in worklist. Any idea?

    Thanks.

    ReplyDelete
    Replies
    1. Are you able to see attachment link in any other notification in worklist or this behavior is specific to this custom notification?

      If it's for all notification then check the personalization of this page

      Delete
  2. Respect and that i have a tremendous supply: How Much Remodel House house renovation contractors

    ReplyDelete