0% found this document useful (0 votes)
366 views

Attachments in Workflow Notifications

The document discusses different ways to include attachments in Oracle workflow notifications. There are two types of attachments: attachment links and embedded attachments. Attachment links reference documents already stored in the database and display a link to them. Embedded attachments allow encoding documents into the notification using PL/SQL procedures to generate and encode the attachment data. The document provides examples of creating attributes to store attachment information and calling packages to generate and return attachment data when the attribute is accessed.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
366 views

Attachments in Workflow Notifications

The document discusses different ways to include attachments in Oracle workflow notifications. There are two types of attachments: attachment links and embedded attachments. Attachment links reference documents already stored in the database and display a link to them. Embedded attachments allow encoding documents into the notification using PL/SQL procedures to generate and encode the attachment data. The document provides examples of creating attributes to store attachment information and calling packages to generate and return attachment data when the attribute is accessed.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

Attachments in workflow notifications

In 11.5.10 (Prior to R12), Requisition approval has attachment links. But, PO pproval !oes not have attachment links in approver"s noti#ication. ($%cept the re#erence attachments&e%plaine! 'elo(). Oracle has )iven this option in R12. I# the client version is 11i or prior an! i# the client is askin) #or the attachment links in PO approval then (e nee! to customi*e the (ork#lo(. +et us make it as )eneric rather than mo!ule speci#ic. sho(n 'elo(simple (ork#lo( (ith t(o t,pes o# attachments is

.here are t(o t,pes o# attachments in a noti#ication. One is attachment link an! the other is re#erence attachments (rea!in)/enco!in)&).

0reatin) ttachment +inks$ver, !ocument (hich is attache! in #orms (ill 'e save! in #n!1lo's ta'le an! (ith the unique i! (!ocument i!) in #n!1attache!1!ocuments an! #n!1!ocuments +ook at the 'elo( screenshot to attach an, !ocument #rom #orms.

Query to get the attached document: SELECT fl.file_name, fl.file_data FROM fnd_lobs fl, fnd_attached_documents fad, fnd_documents_tl fdl WHERE fad.pk1_value = TO_CHAR (:l_document_id) AND fad.pk2_value = TO_CHAR (l_revision_number) AND fdl.document_id = fad.document_id AND fdl.media_id = fl.file_id AND fad.entity_name = :l_entity_name;

In a'ove quer,, l_document_id is the primar, ke, o# the mo!ule attachment. i.e i# ,ou are attachin) in PO hea!er level then !ocument i! (ill 'e PO12$ 3$R1I3 value an! i# the user is attachin) !ocuments in line level then !ocument i! (ill 'e PO1+I4$1I3 value. l_entity_name .here are various entit, names #or each mo!ule in hea!er an! line level. $%R$512$ 3$R6 P 1PRO7$0.6 R$51+I4$6 P$R1 B6$40$1 ..$43 40$6 PO12$ 3$R6 OI$12$ 3$R1 .. 028$4.6 PO12$ 3 OI$1+I4$1 .. 028$4.6 PO1+I4$6 P 10O4.RO+1I.$86 l_revision_number Revision num'er is the attachment revision num'er, )enerall, starts (ith 90". ttachment link looks like 'elo(

6teps to )et the attachment link in noti#ication #rom #n!1lo's1. 0reate a attri'ute in (ork#lo( (ith the t,pe as 93ocument"

:here ;alue o# the attri'ute har!co!e to9<43-entit,=OI$1+I4$1 .. 028$4.6>pk1name=R$POR.1+I4$1I3>pk1value=55?1?1" @:e can set it in co!e #or !,namic pick. .he s,nta% shoul! 'e same as a'ove to )et value #rom #n!1lo's, #n!1attache!1!ocuments an! #n!1!ocuments usin) the a'ove mentione! quer,. One more e%ample o# s,nta% #or PO line attachments<43-entit,=PO1+I4$6>pk1name=PO1+I4$1I3>pk1value=AAAAA (po1line1i! value)

2.

0reate a messa)e attri'ute in messa)e in (hich ,ou (ant to sen! the attachment

8essa)e attri'ute internal name shoul! 'e 9B .. 028$4.6". 4o nee! to check the attach content check 'o%. Cive !e#ault t,pe as 9Item attri'ute" an! select the !ocument t,pe item attri'ute (hich (as Dust create! in step 1.

E.

.his is it. Fou can run the (ork#lo( to check the attachment links. 4o limitation #or the num'er o# attachments. 4o restriction #or the t,pe o# the !ocument, ,ou can attach an, #ile. <iles shoul! present in the ta'les #or each !ocument i!.

********************************************************************************* ********************************************************************************* Other t,pe o# attachment is (hich (e can (rite/rea!/enco!e the !ocuments an! #ive it as an attachment. 6ame process as a'ove to create attri'utes, 'ut the s,nta% (ill !i##er an! shoul! check the 9attach content" check 'o% in messa)e attri'utes. 9B .. 02$8$4.6" is not require!. 6eparate pl/sql co!e ((ith stan!ar! parameters) is there to e%ecute the lo)ic. 6teps to create clo'/'lo' attachment1) 0reate an attri'ute o# t,pe 93ocument" 3ra) an! !rop OR 0op, the !ocument an! paste it in 8essa)e attri'utes. 0heck the 9 ttach 0ontent" 0heck 'o%. ttri'ute value is har!co!e! in the 'elo( screenshot. Fou can set it in ,our custom co!e.

2) .here are E various t,pes o# s,nta%es availa'le to create an attachment. 1. 2. E. P+65+ P+65+0+OB P+65+B+OB

6,nta%- P+65+0+OB-GPacka)e.Proce!ureH/Gunique1ke,H

$%- P+65+0+OB-%%1attach1packa)e.%%1noti#1attach1proce!ure/2EI5?2 P+65+ is #or simple plain te%ts, ta'les&not #or lar)e o'Dects. I# (e set the a'ove value to an, !ocument t,pe o# attri'ute, (henever the user tries to access the attri'ute the packa)e.proce!ure (ill call automaticall,. J.his is stan!ar! #unctionalit, )iven ', Oracle K callin) !,namic 65+ ', !oin) su'strin) #rom colon (-) to slash (/)L. .here are some stan!ar! parameters to 'e use! (henever (e use the proce!ure in 'et(een - an! /. .hose parameters are (document_id display_type document document_type IN IN IN IN VARCHAR2, VARCHAR2, OUT NOCOPY BLOB, OUT NOCOPY VARCHAR2)

:here !ocument i! (oul! 'e unique i! like po1hea!er1i!,po1requisition1hea!er1i!, proDect1i! &etc& 3ispla,1t,pes (oul! 'e $%- !ispla,1t,pe -= Mte%t/htmlMN OOOR 9te%t/plain"N 3ocument coul! 'e 0+OB/B+OB .he !atat,pe o# the #ile1!ata column in #n!1lo's is B+OB. 6o i# ,ou are usin) P+65+0+OB then convert/enco!e the !ocument usin) :<18 I+1P.I+.enco!e'lo' packa)e.

3ocument t,pe (oul! 'e mime t,pe. .his coul! 'e p!#/e%cel/html/ms(or!&..etc& 6,nta% #or p!#!ocument1t,pe -=Mapplication/p!#Nname=MQQG#ile1nameHN

E) <or custom (ork#lo(s )enerall, (e set the !ocument attri'ute a#ter creatin) the process i.e 'e#ore startin) the process. +aunch Process = 0reate Process R 6tart Process (In (#1en)ine PI)

P6$P3O 0O3$-- This is the pseudo code. Modify this according to your requirement CREATE OR REPLACE PACKAGE BODY xx_attach_package AS PROCEDURE xx_notif_attach_procedure ( document_id IN VARCHAR2, display_type IN VARCHAR2, document IN OUT BLOB,

document_type ) IS

IN OUT

VARCHAR2

l_docid PLS_INTEGER; l_temp_blob BLOB; --l_file_path VARCHAR2(100) := '/u02/DEV/apps/apps_st/appl/soncus/12.0.0/bin'; l_file_name VARCHAR2 (100); -- := 'Son_attachment_doc.doc'; l_file_on_os BFILE; l_dest_offset NUMBER := 1; l_src_offset NUMBER := 1; l_file_content_type VARCHAR2 (256); BEGIN l_docid := TO_NUMBER (document_id); /*Here we are reading from a file*/ DBMS_LOB.createtemporary (l_temp_blob, CACHE => FALSE); SELECT INTO FROM WHERE file_name, file_content_type, file_data l_file_name, l_file_content_type, l_temp_blob fnd_lobs file_id = 234562; -- Can get it dynamically using document id

--EXECUTE IMMEDIATE('CREATE OR REPLACE DIRECTORY SON_ATTACHMENTS AS '''|| l_file_path||''''); --l_file_on_os:=bfilename('',l_file_name); --dbms_lob.fileopen(l_file_on_os,dbms_lob.file_readonly); -- DBMS_LOB.LOADBLOBFROMFILE (dest_lob => l_temp_blob, src_bfile=>l_file_on_os, amount=>dbms_lob.getlength(l_file_on_os) ,dest_offset=>l_dest_offset --in out parameter ,src_offset =>l_src_offset);

-----

--dbms_lob.fileclose(l_file_on_os); DBMS_LOB.createtemporary (document, CACHE => FALSE); DBMS_LOB.COPY (document, l_temp_blob, DBMS_LOB.getlength(l_temp_blob)); /*We have to determine document_type which is nothing but the mime type document_type := 'image/jpg; name=filename.jpg'; Depending on the extension of the document the MIME type is determined. For simplicity we are hard coding here*/ document_type := 'application/pdf;name=' || l_file_name; --commit; EXCEPTION WHEN OTHERS THEN wf_core.CONTEXT ('XX_ATTACH_PACKAGE',

'XX_NOTIF_ATTACH_PROCEDURE', document_id, display_type ); RAISE; END xx_notif_attach_procedure; /****************************************************************/ PROCEDURE son_attachment_wf IS l_itemtype VARCHAR2 (30) := 'SONCUSAT'; l_itemkey VARCHAR2 (300); -- l_file_name VARCHAR2(100) := '24Mar2010.xls'; l_document_id NUMBER := 234562; -- You can get document id from the standard workflows (ex: po_header_id, expense_report_header_id...) while customizing standard workflows BEGIN l_itemkey := 'SONCUSAT' || TO_CHAR (SYSDATE, 'dd/mm/yyhh:mm:ss'); wf_engine.createprocess (l_itemtype, l_itemkey, 'SON_CUS_ATTACH_PROCESS' ); wf_engine.setitemattrdocument (itemtype => l_itemtype, itemkey => l_itemkey, aname => 'SON_ATTACHMENT_ATTRIBUTE', documentid => 'PLSQLBLOB:xx_attach_package.xx_notif_attach_procedure/' || l_document_id

); wf_engine.startprocess (l_itemtype, l_itemkey); END; /****************************************************************/ END xx_attach_package; /

J@ P+/65+ 0+OB !ocument that ,ou inclu!e as an attachment to a noti#ication can contain a P3< or R.< !ocument or, i# ,our !ata'ase version is OracleSi 3ata'ase or hi)her, other 'inar, !ata that is enco!e! to 'ase?I. Fou shoul! #irst store the !ocument in the !ata'ase as a 'inar, lar)e o'Dect (B+OB) an! then convert the !ocument into a 0+OB as part o# the P+/65+ proce!ure that )enerates the 0+OB. Fou can use the P.+1R :.0ast1.o1; R02 R2 #unction to convert the !ata #rom the B+OB into ; R02 R2 !ata that ,ou (rite to a 0+OB. I# ,our !ata'ase version is OracleSi 3ata'ase or hi)her, ,ou can optionall, use the :<18 I+1P.I+.$nco!eB+OB proce!ure to enco!e the 'inar, !ata to 'ase?I. Note: Fou can call :<14O.I<I0 .IO4.:rite.o0lo'() to help 'uil! a 0+OB ', appen!in) a strin) o# character !ata to it.L

Fou can (rite usin) 2.8+ ta)s to create ta'les/column hea!er/!ata in noti#ication usin) P+65+-Gpacka)e.proce!ureH/G!ocument1i!H

0ompare! to the a'ove attachment process, attachment links are simple to create. :henever the user (ants to )ive the !ata ((hatever he/she has entere!) as an attachment ((hich is not ,et save! in #n!1lo's/#n!1!ocuments) then (e can use the a'ove s,nta% to (rite the !ata/creatin) the !ocument/sen! as an attachment.

You might also like