Using this simple technique, you can generate email notifications with attachments for Word or PDF or any other binary objects.
Oracle has made sending such documents as attachments with notifications very straightforward. In the below example, I am assuming only one attachment per notification. However, you can create as many Attachment attributes you wish, and also can programmatically control how many attachments are sent per transactions. Anyway, below are four simple steps for sending Workflow Notifications with Attachments.
Step 1
As in the picture, workflow Message “XX_G4G Notification With Attachment” is defined. This message will be referenced by the Notification that sends either MsWord or PDF or any other binary attachment as email.
Step 2.
Define an attribute to the message defined in Step 1. This is shown in the picture below. Following must be noted:-
Type: Document

Source: Send
Frame Target: New Window
Attach Content: Yes.
If you had dragged the Attribute from Workflow level into this message, then default sub-section will be populated automatically.
Step 3.
After executing the wf_engine.createprocess and before executing wf_engine.startprocess, we need to set a value for the attribute defined in Step 2. This can be done by calling wf_engine.setitemattrdocument as below
wf_engine.setitemattrdocument
(itemtype=>'XG4GWFIT'
, itemkey=>'XG4GWFIT' || l_item_key
, aname=>'XX_G4G_ATTACHMENT1'
, documentid =>'PLSQLBLOB:xx_g4g_package.xx_notif_attach_procedure/' || to_char(l_file_id));
Please note the manner in which parameter documented is assigned. The syntax is PLSQLBLOB:<package name>.<procedure name>/<unique id to identify binary file> . In my example, I am capturing the file_id from fnd_lobs. In your case this ID will be derived depending upon whether you are looking for PO Attachment or say an attachment to Oracle Sales Order or a Resume in iRecruitment or some course notes in oracle Learning Management.
Step 4.
Handle the execution of the procedure, in this case xx_notif_attach_procedure
PROCEDURE xx_notif_attach_procedure
(
document_id IN VARCHAR2
,display_type IN VARCHAR2
,document IN OUT BLOB
,document_type IN OUT VARCHAR2
) IS
lob_id NUMBER;
bdoc BLOB;
content_type VARCHAR2(100);
filename VARCHAR2(300);
BEGIN
set_debug_context('xx_notif_attach_procedure');
lob_id := to_number(document_id);
-- Obtain the BLOB version of the document
SELECT file_name
,file_content_type
,file_data
INTO filename
,content_type
,bdoc
FROM fnd_lobs
WHERE file_id = lob_id;
document_type := content_type || ';name=' || filename;
dbms_lob.copy(document, bdoc, dbms_lob.getlength(bdoc));
EXCEPTION
WHEN OTHERS THEN
debug('ERROR ^^^^0018 ' || SQLERRM);
wf_core.CONTEXT('xx_g4g_package'
,'xx_notif_attach_procedure'
,document_id
,display_type);
RAISE;
END xx_notif_attach_procedure;
Please note the following:-
Note 1. In step 3, the value of Unique File id that is passed in after / gets translated into document_id in step 4. This translation occurs within the workflow engine, when it splits the pl/sql name from parameter.
Note 2. Proecdure xx_notif_attach_procedure must be defined in the package specification too.
Note 3. This procedure has an out parameter “document IN OUT BLOB”
Note 4. The value from the Oracle Blob column is fetched into blob variable bdoc from fnd_lobs.
Note 5. Next you can use dbms_lob.copy to copy the value from blob variable into out parameter for notification.
Thanks for reading this article. Kindly share this knowledge with your colleagues as this happens to be a very useful feature of Oracle Workflows.
Thanks,
Anil Passi
written by nasir , November 14, 2006
written by nasir , November 14, 2006
written by Anil Passi , November 15, 2006
written by Anil Passi , November 15, 2006
written by Anil Passi , January 21, 2007
I assume you are doing the below:-
You have subscribed to the event that gets fired after IRC vacancy creation. This Workflow subscription is then send notification with attachment.
Now to answer your question, well it is answered in Step 3 in this article. After the package dot procedure name you are passing the File ID from which blob can be derived. I guess IRC uses its own table to store those attachments[does not use FND_LOBS]. THe document id in this case will be the id that you assign to the attribute[of type document].
Regarding the package spec and body, you can define in whatever way you wish. However the package procedure that gets assigned to attribute will have parameters of
document_id IN VARCHAR2
,display_type IN VARCHAR2
,document IN OUT BLOB
,document_type IN OUT VARCHAR2
Thanks,
Anil Passi
written by umesh , January 21, 2007
can you tell me..
i> how in parameters document_id, display_type will get pass in the procedure xx_notif_attach_procedure
ii> how exactly package specificatin & body for xx_g4g_package will look like.
i will be very greatful if you can tell me, i am ref. this article for sending an attachment through notification after creation of vacancy in the irecruitment.
regards,
Umesh
written by Anil Passi , January 21, 2007
I assume you are doing the below:-
You have subscribed to the event that gets fired after IRC vacancy creation. This Workflow subscription is then send notification with attachment.
Now to answer your question, well it is answered in Step 3 in this article. After the package dot procedure name you are passing the File ID from which blob can be derived. I guess IRC uses its own table to store those attachments[does not use FND_LOBS]. THe document id in this case will be the id that you assign to the attribute[of type document].
Regarding the package spec and body, you can define in whatever way you wish. However the package procedure that gets assigned to attribute will have parameters of
document_id IN VARCHAR2
,display_type IN VARCHAR2
,document IN OUT BLOB
,document_type IN OUT VARCHAR2
Thanks,
Anil Passi
written by umesh , January 21, 2007
can you tell me..
i> how in parameters document_id, display_type will get pass in the procedure xx_notif_attach_procedure
ii> how exactly package specificatin & body for xx_g4g_package will look like.
i will be very greatful if you can tell me, i am ref. this article for sending an attachment through notification after creation of vacancy in the irecruitment.
regards,
Umesh
written by Vamsi Mohan , March 16, 2007
I tried this in 11.5.8 and i got the following error when i clicked on the attachment icon in the notification.
fnd_document_management.get_launch_document_url(plsqlblob:my_procedure1/10)
Wf_Notification.GetAttrDoc(134824, ACN_DOC_ATTR, text/html)
Wfa_Html.show_plsql_doc(134824, ACN_DOC_ATTR)
I have created the procedure as myprocedure1 and passing the constant 10.
When i looked at the signature of the procedure fnd_document_management.get_launch_document_url it has the following parameters
username
document_identifier
display_icon
launch_document_URL
but in the error stack i could see only the document URL. Do i need to do any setup?
Thanks
Vamsi
written by Ram , April 13, 2007
PO Approval Notification does not contain the Attachment icon, to view the attached documents in the PO.. (whereas, requisition notification contains this attachment view facility)
How do I customize this?? Can you help us please..
Regards,
Ram
written by Ram , April 13, 2007
PO Approval Notification does not contain the Attachment icon, to view the attached documents in the PO.. (whereas, requisition notification contains this attachment view facility)
How do I customize this?? Can you help us please..
Regards,
Ram
written by Anil Passi , April 14, 2007
This is due to the Workflow Message Attribute.
Have a look at below link
http://docs.google.com/Doc?id=dcfd8fsc_52dqr7kr
You may either delete it from Req or develop something similar for PO
The workflows in question are:-
POAPPRV
PO Approval
AND
REQAPPRV
PO Requisition Approval
Thanks,
Anil Passi
written by Ajay Talluri , July 09, 2007
This is a great document. I have used the same to send the output of a concurrent program to an intended user using the above method. But When I am send the notification I am getting the following error.
Error Name = WF_ERROR
Error Message = [WF_ERROR] ERROR_MESSAGE=3835: Error '-20002 - ORA-20002: [WFMLR_DOCUMENT_ERROR]' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'. ERROR_STACK= xx_email_report.xx_notif_attach_procedure(831149, text/html) Wf_Notification.GetAttrblob(769915, XM_ATTACH, text/html) WF_XML.GetAttachment(769915, text/html) WF_XML.GetAttachments(769915, http://aperpppd.cellc.net:8002/pls/PPRD, 2136) WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 769915) WF_XML.Generate(oracle.apps.wf.notification.send, 769915) WF_XML.Generate(oracle.apps.wf.notification.send, 769915) Wf_Event.setMessage(oracle.apps.wf.notification.send, 769915, WF_XML.Generate)
Wf_Event.dispatch_internal()
Error Stack =
Activity Id = 224318
Activity Label = XX_USER_ACCESS:XX_NOTIFICATION Result Code = #MAIL Notification Id = 769915 Assigned User = ATALLURI
Would you please help me in getting the problem solved.
Thanks in Advance.
written by vivek , September 13, 2007
I want to add Comments in the FYI Notification, and pass it to the next Approver, for this i have made two rules having category as 'FYI' and 'Approver'. My process is explained below,
A-->B-->C, over here 'A' is the initiator 'B' is the FYI reciever and 'C' is the final approver, i need to design the process so that when 'A' enters some comments it should be visible to 'B' and when 'B' enters some comments 'C' should be able to view all comments i.e. given by 'A' and 'B'.
Please provide some information on the approach basically i am unable to carry forward and write comments.
Regards,
Vivek
written by rahul pardeshi , October 18, 2007
to runa concurrent program report from oracle workflow
and then attac the output of the report to a notification
the output of the report is PDF ( from XML Publisher)
Thanks
Rahul
written by nagender , October 22, 2007
I need to send a report output as an attachment in WF (XML publisher output).
I have got the request id and the path of the output file.
But Now I am unable to send this output file as an attachment to the user using WF.
Can you help me....
I can send the URL(link) using fnd.request.add_notification() but I need to send it as an attachment.
Thanks,
Nagender
written by Rahulq , October 22, 2007
workflow
my client nned it
greatly appreciate your help
thanks
rahul
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
written by mdmravi , October 25, 2007
How do i find the path where concurrent program output PDF is stored. here u have used fnd_lobs. How can i capture , concurrent program o/p file here.
regards
ravi
written by SandeepSomvanshi , October 30, 2007
I have a question related with normal workflow notifications. Can i send more than 32k size message as a notification's content.
Regards,
Sandeep
written by subhankar , October 30, 2007
I am facing similar error
Error Name = WF_ERROR
Error Message = [WF_ERROR] ERROR_MESSAGE=3835: Error '-20002 - ORA-20002: [WFMLR_DOCUMENT_ERROR]' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'.
...
...
while trying to attach PDF documents(PLSQLBLOB) to the notificatons..any idea what can be possible causes for the same.
Thanks
Subhankar
written by Abhishek_Gupta , November 13, 2007
I want to send FYI and approve notification for vacancy approval.
Can you tell me how i can do that?
My Req is once some approve vacancy i need to send FYI to third person.
written by agupta , November 13, 2007
I have workflow working already for vacancy approval. What i need is when some one approves vacancy, it should send FYI to third person. So i can add this req in existing workflow so that i can achieve FYI notification along with approvals.
written by rose , November 16, 2007
Hi anil,
How do i find the path where concurrent program output PDF is stored. here u have used fnd_lobs. How can i capture , concurrent program o/p file here.
written by Sachin Ahuja , December 13, 2007
I've one more doubt again. How we are putting the data into FND_LOBS Table? i.e any api which I can use to insert data into FND_LOBS.
In Detail:
I have data in one table and will be sending notification based on data in it. Now as soon as notification is send we want to delete the records in table. I tried using CLOB for it. But as soon as records gets deleted previously send notifications also fails to open.
So I thought if I can put my data in FND_LOB as some rtf file and will base my attachment procedure to fetch the data from FND_LOBS and for this I need an api to insert the data into FND_LOBS.
Thanks & Regards
Sachin Ahuja
written by vicky330 , January 02, 2008
The concurrent program output path can be retrieved from fnd_concurrent_requests table. The column name is outfile_name.
Thanks,
Vicky
written by Inanc , June 24, 2008
written by Inanc , July 04, 2008
I have benefited from this article and also advanced to a one step further by attaching multiple files.
Here how it is done.
I have used this method in PO Approval (POAPPRV) Workflow.
Step 1
---------------------
Create a new custom function
Name: xxxt_custom_pkg.xxxt_set_custom_attributes (Sample Name)
Purpose: This function assigns values to document attributes in a cursor, limited to 10 files. A little modification done to the script above.
Script:
**************************************************
procedure xxakb_set_attr_doc (itemtype in varchar2,
itemkey in varchar2,
actid in number,
funcmode in varchar2,
resultout out NOCOPY varchar2) is
l_file_id number;
l_document_id number;
i number;
cursor c is
SELECT
distinct
dt.media_id
FROM fnd_document_datatypes dat,
fnd_document_entities_tl det,
fnd_documents_tl dt,
fnd_documents d,
fnd_document_categories_tl dct,
fnd_doc_category_usages dcu,
fnd_attachment_functions af,
fnd_attached_documents ad
WHERE d.document_id = ad.document_id
AND dt.document_id = d.document_id
AND dt.LANGUAGE = USERENV ('LANG')
AND dct.category_id = d.category_id
AND dct.LANGUAGE = USERENV ('LANG')
AND dcu.category_id = d.category_id
AND dcu.attachment_function_id = af.attachment_function_id
AND d.datatype_id = dat.datatype_id
AND dat.LANGUAGE = USERENV ('LANG')
AND ad.entity_name = det.data_object_code
AND det.LANGUAGE = USERENV ('LANG')
AND dcu.enabled_flag = 'Y'
AND pk1_value=l_document_id --po_header_id
and function_name='inbox';
BEGIN
i:=1;
l_document_id := wf_engine.GETITEMATTRNUMBER (itemtype, itemkey, 'DOCUMENT_ID');
for r in c loop
wf_engine.setitemattrdocument
(itemtype => itemtype,
itemkey => itemkey,
aname => 'FILE_NO_'||i, --Name of the attribute with the number preceding
documentid => 'PLSQLBLOB:xxxt_custom_pkg.xx_notif_attach_procedure/'
|| TO_CHAR (r.media_id)
);
i:=i+1;
exit when i=10;
end loop;
resultout := 'COMPLETE:SUCCESS';
EXCEPTION WHEN OTHERS
THEN
resultout := 'COMPLETE:SUCCESS';
END;
**************************************************
Step 2:
Create as many attributes as you want in your POAPPRV workflow. Do not forget to put them under the message. (I used PO_PO_APPROVE message)
1st: Internal Name: FILE_NO_1
2nd: Internal Name: FILE_NO_2 .....so on.
Type: Document
Source: Send
Frame Target: Full Window
Also do not forget to select "Attach Content" when the attribute is under the message.
This works fine for me on 11.5.9 instance.
written by Dillibabu , July 09, 2008
I have a custom workflow that sends notification with multiple attachments using #ATTACHMENTS.
When I pass the entity, pk1name, pk1value it doesn't return anything.
I checked the fnd_documents & fnd_attached_documents for the pk1value, it exists.
Am I missing something in the setup.
Your help is Appreciated.
Thanks
R.Dillibabu
written by Rekha , July 15, 2008
I have a requirement wherein I need to send varying number of attachments in workflow notification, based on a condition. Is it possible to create attachment attributes dynamically??
Can you please help me in this regard.
Thanks,
Rekha
written by Sameer , July 30, 2008
My requirement is to launch the custom orcale application form from notification.
Can u plz me.....
Thanks,
Sameer
written by Anil Passi- , July 30, 2008
PO Requisition Approval workflow has this functionality inbuilt, whereby the notification has Purchase Order form link as attachment
You can reverse engineer that to find the steps.
Thanks,
Anil Passi
written by Krish , October 17, 2008
I want create an document type item attribute and in the default value i want to specify as plsqlblob:pkg.proc/idocumentid
where documentid is also an item attribute...for which value will set using a function before the notification....
so that the api wf_engine.setitemattrdocument need not to use..
Thanks,
Kittu.
written by Sitaram , November 11, 2008
Thank you for sharing knowledge. I am able to send binary attachments, but the workflow document attribute name is coming as file name. How do we get the original filename for the attachment.
I have uploaded a file capexappr.xls; when the notification is received by approver, the attached file name is coming as capex_attachement (which is document attribute name)
what could be the reason
written by Sitaram , March 12, 2009
Using your procedure i was able attach documnets (word/pdf/excel) in workflow. but users whose preference set to HTML mail with attachments, they are able to receive attachments thru workflow notification, but the content is missing or getting junk.
The same user when login into system and from notification summary, was able to view documents properly.
What could be the issue.
written by Anil Passi-- , March 13, 2009
If so, them change the WF Role preference in WF before firing the notification
written by Sitaram , March 13, 2009
MAILATTH,
MAILHTML,
MAILHTM2.
We are using Apps 11.5.9 version.
written by Thomas , June 26, 2009
Where you able to solve this problem?.Any inputs really appreciated?..Im running into the same problem now.
written by Sitaram , August 21, 2009
We are still living with this problem. One observation is that if you upload (rtf files, and pdf files with ver 1.1) it is working. user not able to open any email attachments (thru notification) for doc/excel/images. mostly there is some kind of encoding not happening inside workflow packages /while converting to email notification with attachments. we are on wf 2.6.3 ver.
written by Sitaram , August 27, 2009
What kind of error / message is coming when opening work flow notification email with attachments. you are on which ver of EBS & workflow?
written by Moumita , February 25, 2010
I need to show all attachments for a project in the project approval notifications. I assume the above solution will work for datatype='FILE'. What about short text and Long Text? How can I show them as attachments? Will the same program suffiice
written by Rich Andryszewski , April 23, 2010
I am trying to attach file which is a message/rfc822 yet I encounter in stack
[WF_ERROR] ERROR_MESSAGE=3835: Error '-20002 - ORA-20002: [WFMLR_DOCUMENT_ERROR]' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'.
ERROR_STACK=
Wf_Notification.GetAttrblob(36803186, POAPPRV_ATT, text/html)
WF_XML.GetAttachment(36803186, text/html)
WF_XML.GetAttachments(36803186, http://neworadev.staywell.com:8003/pls/TEST, 4779)
WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 36803186)
WF_XML.Generate(oracle.apps.wf.notification.send, 36803186)
WF_XML.Generate(oracle.apps.wf.notification.send, 36803186)
Wf_Event.setMessage(oracle.apps.wf.notification.send, 36803186, WF_XML.Generate) Wf_Event.dispatch_internal()
written by Rich Andryszewski , April 23, 2010
written by Anil Kumar Mettu , June 01, 2010
An Error occurred in the following Workflow.
Item Type = POAPPRV
Item Key = 60383-243513
User Key =40515
Error Name = WF_ERROR
Error Message = [WF_ERROR] ERROR_MESSAGE=3835: Error '-20002 - ORA-20002: [WFMLR_DOCUMENT_ERROR]' encountered during execution of Generate function 'WF_XML.Generate' for event 'oracle.apps.wf.notification.send'. ERROR_STACK=
GNE_PO_CREATE_FILE_ATTACHMENT.Gne_Create_File_Attachment(60383-243513
OAPPRV, text/html) Wf_Notification.GetAttrblob(207046, PO_REPORT, text/html)
WF_XML.GetAttachment(207046, text/html)
WF_XML.GetAttachments(207046, http://gnedxbebsdev.gerab.ae:8003/pls/DEV, 850
WF_XML.GenerateDoc(oracle.apps.wf.notification.send, 207046)
WF_XML.Generate(oracle.apps.wf.notification.send, 207046)
WF_XML.Generate(oracle.apps.wf.notification.send, 207046)
Wf_Event.setMessage(oracle.apps.wf.notification.send, 207046, WF_XML.Generate)
Wf_Event.dispatch_internal()
Error Stack =
Activity Id = 124108
Activity Label = NOTIFY_APPROVER_SUBPROCESS:GNE_PO_NOTI_TO_CEO
Result Code = #MAIL
Notification Id = 207046
Code is Here
procedure Gne_Create_File_Attachment (document_id in varchar2,
display_type in varchar2,
document in out blob,
document_type in out varchar2)
is
l_itemtype varchar2(100);
l_itemkey varchar2(100);
l_output_directory varchar2(30);
l_filename varchar2(255);
src_loc bfile;
bdoc blob;
src_offset number := 1;
dst_offset number := 1;
amount number;
l_request_id varchar2(100);
begin
l_itemtype := substr(document_id, 1, instr(document_id, ':') - 1);
l_itemkey := substr(document_id, instr(document_id, ':') + 1, length(document_id) - 2);
select attribute4
into l_request_id
from po_headers_all
where to_char(PO_HEADER_ID)=l_itemtype;
l_output_directory := 'APPLCSF/APPLOUT';
l_filename := 'o'||l_request_id;
src_loc := bfilename(l_output_directory,l_filename);
dbms_lob.createTemporary(bdoc, FALSE, dbms_lob.call);
dbms_lob.fileopen(src_loc, dbms_lob.file_readonly);
dbms_lob.loadblobfromfile(bdoc,src_loc,dbms_lob.lobmaxsize,src_offset,dst_offset);
dbms_lob.fileclose(src_loc);
amount := dbms_lob.getLength(bdoc);
dbms_lob.copy(document,bdoc,amount,1,1);
document_type := 'application/pdf; name=attach.pdf';
EXCEPTION
WHEN OTHERS THEN
wf_core.CONTEXT('GNE_PO_CREATE_FILE_ATTACHMENT'
,'Gne_Create_File_Attachment'
,document_id
,display_type);
RAISE;
end GNE_Create_File_Attachment;
PROCEDURE Gne_Assign_wf_Attribute(
itemtype IN VARCHAR2,
itemkey IN VARCHAR2,
actid IN NUMBER,
funcmode IN VARCHAR2,
resultout OUT NOCOPY VARCHAR2)
IS
v_user_name varchar2(100);
BEGIN
IF FUNCMODE = 'RUN' THEN
wf_engine.setitemattrdocument
(itemtype => itemtype
, itemkey => itemkey
, aname => 'PO_REPORT'
, documentid =>'PLSQLBLOB:GNE_PO_CREATE_FILE_ATTACHMENT.GNE_Create_File_Attachment/'
|| itemkey
|| ':'
|| itemtype);
end if;
EXCEPTION
WHEN OTHERS THEN
wf_core.CONTEXT('GNE_PO_CREATE_FILE_ATTACHMENT'
,'Gne_Assign_wf_Attribute'
,itemtype
,itemkey);
RAISE;
END Gne_Assign_wf_Attribute;
Can Any Body Please help me....
It is very urgent..
Thanks In Advance
written by David charan.D , June 11, 2010
I have a requirement to attach a document stored as BLOB in database as a link in workflow notification.The link (document) should be visible and opened both from the workflow notification in the workflow admin notification queue and notification mail the approver receives.
I have used the example code you have given and getting the document Id and storing it in the item attribute of type Document.
Your code will send the document as attachment in the mail.
Please help me how to attach the document as a link in the notification.
Any help is highly appreciated!
Thanks
David
written by ssingh1976 , July 12, 2010
| < Prev | Next > |
|---|






