Attaching Concurrent Program Output As Workflow Email Notification Attachment
Attaching Concurrent Program Output As Workflow Email Notification Attachment
Notification Attachment
by Shailender ThallamMay 17, 2016
This article explains how to attach a concurrent program output as a Workflow email notification.
Prerequisites
Steps to Implement
Below is the sample PL/SQL procedure which takes Concurrent Request ID as input parameter and
returns the media_id of the BLOB document created
1 PROCEDURE load_inv_pdf_p (
2 p_conc_req_id IN apps.fnd_concurrent_requests.request_id%TYPE,
3 p_project_number IN apps.pa_projects_all.segment1%TYPE,
4 p_draft_invoice_num IN apps.pa_draft_invoices_all.draft_invoice_num%TYPE,
6 )
7 -- +===================================================================+
8 -- | Name : load_inv_pdf_p |
10 -- | BLOB file_id |
11 -- | Parameters : |
12 -- | |
17 -- | |
18 -- +===================================================================+
19 IS
20 lr_row_id ROWID;
21 ln_document_id NUMBER;
22 ln_media_id NUMBER;
24 ln_category_id NUMBER;
25 lb_blob BLOB;
26 lb_bfile BFILE;
31 ln_count NUMBER;
32 lc_cp_short_name apps.fnd_concurrent_programs.concurrent_program_name%TYPE;
33 --
34 BEGIN
35 --
37 --
38 SELECT program_short_name
39 INTO lc_cp_short_name
40 FROM apps.fnd_conc_req_summary_v
42
45 'Project#'
46 || p_project_number
47 || '_DraftInvoice#'
48 || p_draft_invoice_num
49 || '.pdf';
50 lc_description :=
51 'Draft Invoice#'
52 || p_draft_invoice_num
54 || p_project_number;
55 --
58
59 --
60 BEGIN
61 SELECT category_id
62 INTO ln_category_id
63 FROM apps.fnd_document_categories_tl
66 EXCEPTION
67 WHEN OTHERS
68 THEN
69 --
70 lb_go := FALSE;
71 p_file_id := -1;
72 DBMS_OUTPUT.put_line (
74 );
75 --
76 END;
77
78 --
80 --
81 BEGIN
pp _ _p g _
84 (x_rowid => lr_row_id,
91 x_datatype_id => 6,
94 x_security_type => 1,
105 );
109 --
110 EXCEPTION
112 THEN
115 DBMS_OUTPUT.put_line (
117 || SQLERRM
118 );
119 END;
120
121 --
122 --Creating Empty BLOB with reference to the above ceated document
123 --
124 BEGIN
127
138 )
141 EXCEPTION
143 THEN
144 lb go := FALSE;
_g ;
145 p_file_id := -1;
146 DBMS_OUTPUT.put_line (
148 );
149 END;
150
151 --
152 BEGIN
153 --
155 --
157 --
159 --
161 --
163 --
165 --
166 --load the file from disk to the table directly using lb_blob created in previous
167 --
170 --
172 --
174 --
175 EXCEPTION
177 THEN
178 DBMS_OUTPUT.put_line (
180 || lc_actual_file_name
182 || SQLERRM
183 );
184 --
185 ROLLBACK;
186 END;
187
188 --
189 COMMIT;
190 --
2
4 IS
5 PROCEDURE set_att_invoice_media_id (
6 p_item_key apps.wf_notifications.item_key%TYPE
7 );
8
9 --
10 PROCEDURE notif_attach_procedure (
11 document_id IN VARCHAR2,
12 display_type IN VARCHAR2,
15 );
16 END xx_test1_pkg;
17 /
18
19 --
20 --
21
23 AS
24 -- +===================================================================+
25 -- | Name : notif_attach_procedure |
27 -- | Parameters : |
28 -- | |
35 -- | |
36 -- | RETURNS : No Return |
37 -- +===================================================================+
38 PROCEDURE notif_attach_procedure (
39 document_id IN VARCHAR2,
40 display_type IN VARCHAR2,
43 )
44 IS
45 lob_id NUMBER;
46 bdoc BLOB;
49 BEGIN
50 --
52 --
53 --–set_debug_context('notif_attach_procedure');
55 --
57 --
59 --
61
62 --
64 --
69
70 --
72 --
73 --Copying the blob document 'document' to the temporary blob document 'bdoc'
74 --
76 --
78 --
79 EXCEPTION
80 WHEN OTHERS
81 THEN
82 --
84 || SQLERRM
85 );
86 --
87 END notif_attach_procedure;
88
89 --
90 --
91 PROCEDURE set_att_invoice_media_id (
92 p_item_key apps.wf_notifications.item_key%TYPE
93 )
94 IS
95 -- +===================================================================+
96 -- | Name : set_att_invoice_media_id |
98 -- | Parameters : |
99 -- | |
101 -- |
102 -- +===================================================================+
109 BEGIN
110 --
112 --
113 --
115 --
121 );
122 --
124 --
125 apps.wf_engine.setitemattrtext
130 (l_doc_id)
132 );
133 --
135 --
138 );
139 --
141 --
142 EXCEPTION
144 THEN
145 --
147 || SQLERRM
148 );
149 --
152 /
Create a workflow with two types of attributes, one is of type ‘Text’ (XX_BLOB_DOC_ID) and other is of
type ‘Document’ (XX_DRAFT_INV_FILE_ATTACH)
Workflow Structure:
Workflow Process
Document type attribute
Value: plsqlblob:XX_TEST1_PKG.notif_attach_procedure/&XX_BLOB_DOC_ID
file_id of blob document should be set to attribute XX_BLOB_DOC_ID and it should be passed as
parameter to Document type attribute XX_DRAFT_INV_FILE_ATTACH which in turn calls procedure
“XX_TEST1_PKG.notif_attach_procedure” which copies the original blob document in fnd_lobs to
workflow notification.
DECLARE
BEGIN
xx_test1_pkg.set_att_invoice_media_id (l_item_key);
END;