[Home] [Help]
PACKAGE BODY: APPS.CS_WF_AUTO_NTFY_UPDATE_PKG
Source
1 PACKAGE BODY CS_WF_AUTO_NTFY_UPDATE_PKG AS
2 /* $Header: cswfautb.pls 120.19 2006/11/16 01:13:54 klou noship $ */
3
4 -- --------------------------------------
5 -- Constants used in this package
6 -- --------------------------------------
7
8 -- cs_newline varchar2(1) := chr(10);
9 cs_delimiter varchar2(1) := ' ';
10 l_amp VARCHAR2(8) := fnd_global.local_chr(38);
11 l_new_line VARCHAR2(8) := fnd_global.newline;
12 dbg_msg VARCHAR2(4000);
13
14 /****************************************************************************
15 Forward Declaration
16 ****************************************************************************/
17
18 PROCEDURE pull_from_list(itemlist IN OUT NOCOPY VARCHAR2,
19 element OUT NOCOPY VARCHAR2);
20
21 PROCEDURE SetWorkflowAdhocUser(
22 p_wf_username IN OUT NOCOPY VARCHAR2,
23 p_email_address IN VARCHAR2,
24 p_display_name IN VARCHAR2 DEFAULT NULL);
25
26 PROCEDURE SetWorkflowAdhocRole(
27 p_wf_rolename IN OUT NOCOPY VARCHAR2,
28 p_user_list IN VARCHAR2) ;
29
30 PROCEDURE Set_HTML_Notification_Details
31 ( p_itemtype IN VARCHAR2,
32 p_itemkey IN VARCHAR2,
33 p_actid IN NUMBER,
34 p_funmode IN VARCHAR2,
35 p_contact_type IN VARCHAR2,
36 p_contact_id IN NUMBER,
37 p_request_id IN NUMBER,
38 p_request_number IN VARCHAR2,
39 p_sender IN VARCHAR2,
40 p_email_preference IN VARCHAR2,
41 p_user_language IN VARCHAR2,
42 p_recipient IN VARCHAR2,
43 p_message_name IN VARCHAR2,
44 p_from_status IN VARCHAR2,
45 p_to_status IN VARCHAR2) ;
46
47 PROCEDURE Create_Role_List
48 ( p_itemtype IN VARCHAR2,
49 p_itemkey IN VARCHAR2,
50 p_actid IN NUMBER,
51 p_funmode IN VARCHAR2,
52 p_action_code IN VARCHAR2,
53 p_role_group_type IN VARCHAR2,
54 p_role_group_code IN VARCHAR2);
55
56 -- ***************************************************************************
57 -- * *
58 -- * Service Request Item Type *
59 -- * *
60 -- ***************************************************************************
61
62 -- -----------------------------------------
63 -- | PUBLIC SECTION |
64 -- | Following procedures are customizable |
65 -- -----------------------------------------
66 --
67
68 /*****************************************************************************
69 -- Check_Rules_For_Event
70 -- This procedure corresponds to the CHECK_RULES_FOR_EVENT function
71 -- activity.
72 -- This procedure checks for ALL rules defined for a given business event
73 -- If there are any valid rules defined, then we continue with the process
74 -- flow, otherwise we immediately go to the END activity.
75 --
76 -- Modification History:
77 --
78 -- Date Name Desc
79 -- ---------- --------- ---------------------------------------------
80 -- 09/07/04 RMANABAT Fix for bug 3871457. In cursors sel_primary_contact_csr,
81 -- sel_all_contacts_csr, and sel_all_contacts_csr, changed
82 -- SELECT null notification_template_id to
83 -- SELECT to_char(null) notification_template_id.
84 --
85 -- 27-Jul-05 ANEEMUCH Rel 12.0 changes.
86 --
87 *****************************************************************************/
88
89 PROCEDURE Check_Rules_For_Event( itemtype IN VARCHAR2,
90 itemkey IN VARCHAR2,
91 actid IN NUMBER,
92 funmode IN VARCHAR2,
93 result OUT NOCOPY VARCHAR2 ) IS
94
95 l_event_name VARCHAR2(240);
96 --l_action_code VARCHAR2(30);
97 l_request_number VARCHAR2(64);
98 l_request_id NUMBER;
99 --l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
100 l_event_condition_id VARCHAR2(30);
101 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
102 l_notify_conditions_list VARCHAR2(4000);
103 l_notify_actions_list VARCHAR2(4000);
104 l_update_conditions_list VARCHAR2(4000);
105 l_update_actions_list VARCHAR2(4000);
106 l_list_element VARCHAR2(60);
107 l_ntfy_template_id NUMBER;
108 l_wf_manual_launch VARCHAR2(1);
109
110 l_API_ERROR EXCEPTION;
111
112
113 CURSOR sel_action_csr IS
114 -- This part of the query is for Update Rules
115 SELECT csad.event_condition_id,
116 csad.action_code,
117 to_char(null) notification_template_id,
118 to_char(csad.event_condition_id) || csad.action_code index_cols,
119 to_char(null) role_group_type,
120 to_char(null) role_group_code
121 FROM CS_SR_ACTION_TRIGGERS csat,
122 CS_SR_ACTION_DETAILS csad,
123 CS_SR_EVENT_CODES_B cec
124 WHERE
125 cec.WF_BUSINESS_EVENT_ID = l_event_name
126 and csat.EVENT_CODE = cec.EVENT_CODE
127 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
128 and TRUNC(NVL(csat.end_date_active, SYSDATE))
129 and csad.event_condition_id = csat.event_condition_id
130 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
131 and TRUNC(NVL(csad.end_date_active, SYSDATE))
132 and csat.from_to_status_code IS NULL
133 and (csad.incident_status_id IS NOT NULL OR
134 csad.resolution_code IS NOT NULL)
135 and csat.relationship_type_id IN
136 ( select cil.link_type_id
137 FROM cs_incident_links cil
138 WHERE cil.subject_id = l_request_id)
139 -- We need to add this to differentiate it from notification rules.
140 -- We may have a ntfxn rule without a template_id (partially created).
141 and csad.action_code NOT like 'NOTIFY%'
142 UNION
143 SELECT csad.event_condition_id,
144 csad.action_code,
145 to_char(null) notification_template_id,
146 to_char(csad.event_condition_id) || csad.action_code index_cols,
147 to_char(null) role_group_type,
148 to_char(null) role_group_code
149 FROM CS_SR_ACTION_TRIGGERS csat,
150 CS_SR_ACTION_DETAILS csad,
151 CS_SR_EVENT_CODES_B cec
152 WHERE
153 cec.WF_BUSINESS_EVENT_ID = l_event_name
154 and csat.EVENT_CODE = cec.EVENT_CODE
155 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
156 and TRUNC(NVL(csat.end_date_active, SYSDATE))
157 and csad.event_condition_id = csat.event_condition_id
158 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
159 and TRUNC(NVL(csad.end_date_active, SYSDATE))
160 and csat.from_to_status_code IS NOT NULL
161 and csat.relationship_type_id IS NULL
162 and csat.incident_status_id IS NOT NULL
163 -- We need to add this to differentiate it from notification rules.
164 -- We may have a ntfxn rule without a template_id (partially created).
165 and csad.action_code NOT like 'NOTIFY%'
166 and csad.relationship_type_id IN
167 ( select cil.link_type_id
168 FROM cs_incident_links cil
169 WHERE cil.subject_id = l_request_id)
170 /******************
171 -- For 11.5.9, we are not supporting any Update Rules defined by the user.
172 -- So csad.relationship_type_id will always have a value as defined from the
173 -- seeded Rule from HLD:
174 -- Rule 2: If the status of the service request changes to Closed,
175 -- and it has a (outgoing) Root cause of relationship, then,
176 -- update status of all related service requests to Clear.
177 -- and csad.relationship_type_id IS NULL OR
178 ***************/
179 -- This part of the query is for Notification Rules
180 UNION
181 SELECT csad.event_condition_id,
182 csad.action_code,
183 csad.notification_template_id,
184 to_char(csad.event_condition_id) || csad.action_code index_cols,
185 role_group_type,
186 role_group_code
187 FROM CS_SR_ACTION_TRIGGERS csat,
188 CS_SR_ACTION_DETAILS csad,
189 CS_SR_EVENT_CODES_B cec
190 /* 03/01/2004 - RHUNGUND - Bug fix for 3412833
191 Commenting the following table from the FROM clause since it was resulting
192 in a cartesian join
193
194 CS_SR_ACTION_CODES_B cac
195 */
196 WHERE
197 cec.WF_BUSINESS_EVENT_ID = l_event_name
198 and csat.EVENT_CODE = cec.EVENT_CODE
199 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
200 and TRUNC(NVL(csat.end_date_active, SYSDATE))
201 and csad.event_condition_id = csat.event_condition_id
202 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
203 and TRUNC(NVL(csad.end_date_active, SYSDATE))
204 and csad.notification_template_id IS NOT NULL
205 -- We need to add this since a notification rule can still be created (partially)
206 -- without a message template.
207 and csad.action_code like 'NOTIFY%'
208
209 ORDER BY index_cols;
210
211 sel_action_rec sel_action_csr%ROWTYPE;
212
213 -- Fix similar to 11.5.9 bug 3106572. rmanabat 10/13/03.
214 CURSOR sel_incident_id_csr IS
215 SELECT INCIDENT_ID
216 FROM cs_incidents_all_b
217 WHERE INCIDENT_NUMBER = l_request_number;
218
219 CURSOR sel_incident_number_csr IS
220 SELECT INCIDENT_NUMBER
221 FROM cs_incidents_all_b
222 WHERE INCIDENT_ID = l_request_id;
223
224
225 /* RHUNGUND - 04/05/04
226 Fix for bug 3528510
227 The following cursor will catch the scenario if the "relationshipCreated" event is raised
228 for a non-sr object. The wf should ignore link events raised for non-sr objects
229 since suport for non-sr objects is not in current scope of this wf
230 */
231
232 CURSOR check_if_rel_is_sr_csr IS
233 SELECT subject_type FROM
234 cs_incident_links
235 WHERE subject_id = l_request_number;
236 l_subject_type VARCHAR2(35) := null;
237
238
239 BEGIN
240 IF (funmode = 'RUN') THEN
241 l_event_name := WF_ENGINE.GetItemAttrText(
242 itemtype => itemtype,
243 itemkey => itemkey,
244 aname => 'EVENTNAME' );
245
246 l_request_number := WF_ENGINE.GetItemAttrText(
247 itemtype => itemtype,
248 itemkey => itemkey,
249 aname => 'REQUEST_NUMBER' );
250
251 l_wf_manual_launch := WF_ENGINE.GetItemAttrText(
252 itemtype => itemtype,
253 itemkey => itemkey,
254 aname => 'MANUAL_LAUNCH' );
255
256 /* RHUNGUND - 04/05/04
257 Fix for bug 3528510 - Added the following IF block
258 */
259 IF(l_event_name = 'oracle.apps.cs.sr.ServiceRequest.relationshipcreated' OR
260 l_event_name = 'oracle.apps.cs.sr.ServiceRequest.relationshipdeleted') THEN
261
262 l_subject_type := WF_ENGINE.GetItemAttrText(
263 itemtype => itemtype,
264 itemkey => itemkey,
265 aname => 'LINK_SUBJECT_TYPE' );
266
267 If (l_subject_type <> 'SR') THEN
268 l_wf_manual_launch := 'Y';
269 END IF;
270
271 END IF;
272
273
274
275 -- Fix for bug 3106572. rmanabat 09/26/03.
276 IF (l_request_number IS NOT NULL) THEN
277 OPEN sel_incident_id_csr;
278 FETCH sel_incident_id_csr INTO l_request_id;
279 IF (sel_incident_id_csr%NOTFOUND OR l_request_id IS NULL) THEN
280
281 IF((l_event_name = 'oracle.apps.cs.sr.ServiceRequest.relationshipcreated' OR
282 l_event_name = 'oracle.apps.cs.sr.ServiceRequest.relationshipdeleted') AND
283 l_subject_type <> 'SR') THEN
284 CLOSE sel_incident_id_csr;
285 ELSE
286 CLOSE sel_incident_id_csr;
287 raise l_API_ERROR;
288 END IF;
289
290 END IF;
291
292 IF sel_incident_id_csr%ISOPEN THEN
293 CLOSE sel_incident_id_csr;
294 END IF;
295
296 END IF;
297
298
299 -- This check needs to be done for workflows launched manually, i.e., via UI's
300 -- Launch Workflow Tools menu option. Auto notification WF had been launched
301 -- when the SR was saved, so this WF launch is redundant. rmanabat .
302 -- This can be replaced later by using WF_RULE2 default rule function in the
303 -- event subscription, which accepts parameter values as qualifiers like
304 -- what we did in SolutionAdded event subscription.
305
306 IF (nvl(l_wf_manual_launch,'N') = 'N') THEN
307
308
309 -- Knowledge Base says they are passing OBJECT_ID (incident_id) instead of number, so
310 -- make sure both are instantiated here.
311 IF (l_request_number IS NULL) THEN
312
313 l_request_id := WF_ENGINE.GetItemAttrNumber(
314 itemtype => itemtype,
315 itemkey => itemkey,
316 aname => 'OBJECT_ID' );
317
318 OPEN sel_incident_number_csr;
319 FETCH sel_incident_number_csr INTO l_request_number;
320 IF (sel_incident_number_csr%NOTFOUND OR l_request_number IS NULL) THEN
321 CLOSE sel_incident_number_csr;
322 raise l_API_ERROR;
323 END IF;
324 IF sel_incident_number_csr%ISOPEN THEN
325 CLOSE sel_incident_number_csr;
326 END IF;
327
328 WF_ENGINE.SetItemAttrText(
329 itemtype => 'SERVEREQ',
330 itemkey => itemkey,
331 aname => 'REQUEST_NUMBER',
332 avalue => l_request_number);
333
334 END IF;
335
336
337 OPEN sel_action_csr;
338 LOOP
339 FETCH sel_action_csr
340 INTO sel_action_rec;
341 --INTO l_event_condition_id, l_action_code, l_ntfy_template_id;
342 EXIT WHEN sel_action_csr%NOTFOUND;
343
344 l_event_condition_id := TO_CHAR(sel_action_rec.event_condition_id);
345
346 /**************
347 Build a condition_id/action_code list for notification rules.
348 **************/
349 IF (sel_action_rec.notification_template_id IS NOT NULL) THEN
350
351 -- Check for the length, not to exceed max WF text length of 4000.
352 IF (nvl(LENGTH(l_notify_conditions_list), 0) +
353 nvl(LENGTH(l_event_condition_id), 0) + 1) <= 4000 OR
354 (nvl(LENGTH(l_notify_actions_list), 0) +
355 nvl(LENGTH(sel_action_rec.action_code), 0) + 1 ) <= 4000 THEN
356
357 IF l_notify_conditions_list IS NULL THEN
358 l_notify_conditions_list := l_event_condition_id;
359 l_notify_actions_list := sel_action_rec.action_code;
360 ELSE
361 l_notify_conditions_list := l_notify_conditions_list || ' ' || l_event_condition_id;
362 l_notify_actions_list := l_notify_actions_list || ' ' || sel_action_rec.action_code;
363 END IF;
364
365 ELSE
366 /**********
367 If the query results exceeded the max allowable WF text length, then we
368 set an attribute to indicate that we need to re-query again to obtain
369 the remainder of the results which were not put in the initial list.
370 **********/
371 WF_ENGINE.SetItemAttrText(
372 itemtype => itemtype,
373 itemkey => itemkey,
374 aname => 'MORE_NTFY_ACTION_LIST',
375 avalue => 'Y' );
376
377 END IF;
378
379 /**************
380 Build a condition_id/action_code list for update rules.
381 **************/
382 ELSE -- IF (sel_action_rec.notification_template_id IS NOT NULL)
383
384 -- Check for the length, not to exceed max WF text length of 4000.
385 IF (nvl(LENGTH(l_update_conditions_list), 0) +
386 nvl(LENGTH(l_event_condition_id), 0) + 1) <= 4000 OR
387 (nvl(LENGTH(l_update_actions_list), 0) +
388 nvl(LENGTH(sel_action_rec.action_code), 0) + 1 ) <= 4000 THEN
389
390 IF l_update_conditions_list IS NULL THEN
391 l_update_conditions_list := l_event_condition_id;
392 l_update_actions_list := sel_action_rec.action_code;
393 ELSE
394 l_update_conditions_list := l_update_conditions_list || ' ' || l_event_condition_id;
395 l_update_actions_list := l_update_actions_list || ' ' || sel_action_rec.action_code;
396 END IF;
397
398 ELSE
399 WF_ENGINE.SetItemAttrText(
400 itemtype => itemtype,
401 itemkey => itemkey,
402 aname => 'MORE_UPDATE_ACTION_LIST',
403 avalue => 'Y' );
404
405 END IF;
406 END IF;
407 END LOOP;
408 CLOSE sel_action_csr;
409
410
411 IF (l_update_conditions_list IS NOT NULL OR l_notify_conditions_list IS NOT NULL) THEN
412
413 WF_ENGINE.SetItemAttrText(
414 itemtype => itemtype,
415 itemkey => itemkey,
416 aname => 'NTFY_CONDITION_LIST',
417 avalue => l_notify_conditions_list );
418 WF_ENGINE.SetItemAttrText(
419 itemtype => itemtype,
420 itemkey => itemkey,
421 aname => 'NTFY_ACTION_LIST',
422 avalue => l_notify_actions_list );
423 WF_ENGINE.SetItemAttrText(
424 itemtype => itemtype,
425 itemkey => itemkey,
426 aname => 'UPDATE_CONDITION_LIST',
427 avalue => l_update_conditions_list );
428 WF_ENGINE.SetItemAttrText(
429 itemtype => itemtype,
430 itemkey => itemkey,
431 aname => 'UPDATE_ACTION_LIST',
432 avalue => l_update_actions_list );
433
434 /*** This will be used later when we convert our message text to PL/SQL docs.
435 WF_ENGINE.SetItemAttrText(
436 itemtype => itemtype,
437 itemkey => itemkey,
438 aname => 'REQUEST_DETAILS',
439 avalue => 'PL/SQL:RMM_TEST_WF_PKG.SR_PLSQL_DOC_ATTR1/'||
440 l_request_number || 'a');
441 ***/
442
443 result := 'COMPLETE:Y';
444 ELSE
445 result := 'COMPLETE:N';
446 END IF;
447
448 ELSE
449
450 result := 'COMPLETE:N';
451
452 END IF; -- IF (l_wf_manual_launch = 'N')
453
454 ELSIF (funmode = 'CANCEL') THEN
455 result := 'COMPLETE';
456 END IF;
457
458 EXCEPTION
459 WHEN l_API_ERROR THEN
460 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Check_Rules_For_Event',
461 itemtype, itemkey, actid, funmode);
462 RAISE;
463
464 WHEN OTHERS THEN
465 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Check_Rules_For_Event',
466 itemtype, itemkey, actid, funmode);
467 RAISE;
468
469 END Check_Rules_For_Event;
470
471
472 /****************************************************************************
473 -- Check_Notification_Rules
474 -- This procedure corresponds to the CHECK_NOTIFICATION_RULES function
475 -- activity.
476 --
477 -- The procedure checks if there are notification rules defined by checking
478 -- the conditions/actions list. If the list is not empty, then we pull the
479 -- first item on the lists to process. Otherwise, we end the sub-process.
480 --
481 ****************************************************************************/
482
483 PROCEDURE Check_Notification_Rules( itemtype IN VARCHAR2,
484 itemkey IN VARCHAR2,
485 actid IN NUMBER,
486 funmode IN VARCHAR2,
487 result OUT NOCOPY VARCHAR2 ) IS
488
489 l_notify_conditions_list VARCHAR2(4000);
490 l_notify_actions_list VARCHAR2(4000);
491 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
492 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
493 l_element VARCHAR2(100);
494
495
496 BEGIN
497
498 IF (funmode = 'RUN') THEN
499
500 l_notify_conditions_list := WF_ENGINE.GetItemAttrText(
501 itemtype => itemtype,
502 itemkey => itemkey,
503 aname => 'NTFY_CONDITION_LIST');
504 l_notify_actions_list := WF_ENGINE.GetItemAttrText(
505 itemtype => itemtype,
506 itemkey => itemkey,
507 aname => 'NTFY_ACTION_LIST');
508
509
510 IF (l_notify_conditions_list IS NOT NULL AND l_notify_actions_list IS NOT NULL) THEN
511
512 pull_from_list(itemlist => l_notify_conditions_list,
513 element => l_element);
514 l_event_condition_id := TO_NUMBER(l_element);
515
516 pull_from_list(itemlist => l_notify_actions_list,
517 element => l_action_code);
518
519 IF (l_event_condition_id IS NOT NULL AND l_action_code IS NOT NULL) THEN
520
521 WF_ENGINE.SetItemAttrText(
522 itemtype => itemtype,
523 itemkey => itemkey,
524 aname => 'NTFY_CONDITION_LIST',
525 avalue => l_notify_conditions_list );
526 WF_ENGINE.SetItemAttrText(
527 itemtype => itemtype,
528 itemkey => itemkey,
529 aname => 'NTFY_ACTION_LIST',
530 avalue => l_notify_actions_list );
531 WF_ENGINE.SetItemAttrNumber(
532 itemtype => itemtype,
533 itemkey => itemkey,
534 aname => 'NTFY_EVENT_CONDITION_ID',
535 avalue => l_event_condition_id );
536 WF_ENGINE.SetItemAttrText(
537 itemtype => itemtype,
538 itemkey => itemkey,
539 aname => 'NTFY_ACTION_CODE',
540 avalue => l_action_code );
541
542 result := 'COMPLETE:Y';
543
544 ELSE
545 result := 'COMPLETE:N';
546
547 END IF;
548
549 ELSE
550 result := 'COMPLETE:N';
551 END IF;
552
553
554 ELSIF (funmode = 'CANCEL') THEN
555 result := 'COMPLETE';
556 END IF;
557
558 EXCEPTION
559 WHEN OTHERS THEN
560 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Check_Notification_Rules',
561 itemtype, itemkey, actid, funmode);
562 RAISE;
563
564 END Check_Notification_Rules;
565
566
567 /****************************************************************************
568 -- Get_Recipients_To_Notify
569 -- This procedure corresponds to the GET_NTFXN_RECIPIENTS function
570 -- activity.
571 --
572 -- This procedure checks if there are valid recipients for the notification
573 -- rule being processed.
574 -- If more than one recipient is set (as in notifying owners of related SRs),
575 -- then a list of recipients is created which we process one item at a time.
576 ****************************************************************************/
577
578 PROCEDURE Get_Recipients_To_Notify( itemtype IN VARCHAR2,
579 itemkey IN VARCHAR2,
580 actid IN NUMBER,
581 funmode IN VARCHAR2,
582 result OUT NOCOPY VARCHAR2 ) IS
583
584 l_request_number VARCHAR2(64);
585 l_request_id NUMBER;
586 l_event_name VARCHAR2(240);
587 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
588 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
589 l_notify_recipient VARCHAR2(100);
590 l_request_status VARCHAR2(30);
591 l_request_status_temp VARCHAR2(30);
592 l_recipient_role_list VARCHAR2(4000);
593 l_linked_subject_list VARCHAR2(4000);
594 --l_linked_incident_id NUMBER;
595 l_linked_incident_number VARCHAR2(64);
596
597 l_return_status VARCHAR2(1);
598 l_msg_count NUMBER;
599 l_msg_data VARCHAR2(2000);
600 l_owner_role VARCHAR2(320);
601 l_owner_name VARCHAR2(240);
602 l_char_subject_id VARCHAR2(30);
603 l_relationship_type_id CS_SR_ACTION_DETAILS.relationship_type_id%TYPE;
604
605 l_trigger_link_type VARCHAR2(240);
606 l_trigger_link_type_id NUMBER;
607
608 CURSOR sel_link_type_id_csr IS
609 SELECT link_type_id
610 FROM CS_SR_LINK_TYPES_VL
611 WHERE name = l_trigger_link_type;
612
613 CURSOR sel_event_action_csr IS
614 SELECT csad.event_condition_id,
615 csad.action_code,
616 csad.notification_template_id, /** this is the WF message name **/
617 csad.relationship_type_id detail_link_type,
618 csad.role_group_type,
619 csad.role_group_code,
620 csat.from_to_status_code,
621 csat.incident_status_id trigger_incident_status_id,
622 csat.relationship_type_id trigger_link_type
623 FROM CS_SR_ACTION_TRIGGERS csat,
624 CS_SR_ACTION_DETAILS csad,
625 CS_SR_EVENT_CODES_B cec
626 WHERE
627 cec.WF_BUSINESS_EVENT_ID = l_event_name
628 and csat.EVENT_CODE = cec.EVENT_CODE
629 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
630 and TRUNC(NVL(csat.end_date_active, SYSDATE))
631 and csad.event_condition_id = csat.event_condition_id
632 and csad.event_condition_id = l_event_condition_id
633 and csad.action_code = l_action_code
634 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
635 and TRUNC(NVL(csad.end_date_active, SYSDATE))
636 and csad.notification_template_id IS NOT NULL
637 -- We need to add this since a notification rule can still be created (partially)
638 -- without a message template.
639 and csad.action_code like 'NOTIFY%';
640
641 sel_event_action_rec sel_event_action_csr%ROWTYPE;
642
643
644 CURSOR sel_link_csr_1 IS
645 SELECT
646 cil.object_id,
647 cil.link_id,
648 inc.incident_owner_id
649 FROM cs_incident_links cil,
650 cs_incidents_all_b inc
651 WHERE cil.subject_id = l_request_id
652 and inc.incident_id = cil.object_id
653 ORDER BY cil.object_id;
654
655 sel_link_rec sel_link_csr_1%ROWTYPE;
656
657 CURSOR sel_link_csr_2 IS
658 SELECT
659 cil.object_id,
660 cil.link_id,
661 inc.incident_owner_id
662 FROM cs_incident_links cil,
663 cs_incidents_all_b inc
664 WHERE cil.subject_id = l_request_id
665 AND cil.link_type_id = l_relationship_type_id
666 AND inc.incident_id = cil.object_id
667 ORDER BY cil.object_id;
668
669 /*
670 Roopa - bug fix for 2788741
671 For the following actions:
672 NOTIFY_OWNER
673 NOTIFY_OLD_OWNER
674 NOTIFY_NEW_OWNER
675 NOTIFY_OWNER_OF_RELATED_SR
676
677 This activity returns N (to skip notify action) if for the above actions, the SR owner
678 himself has updated the SR
679 */
680 l_incident_owner_id NUMBER;
681 l_resource_id NUMBER;
682 l_user_id NUMBER;
683 l_prev_owner_id NUMBER;
684
685 CURSOR sel_inc_owner_id IS
686 SELECT incident_owner_id FROM cs_incidents_all_b WHERE
687 incident_id = l_request_id;
688
689 CURSOR sel_resource_id IS
690 SELECT resource_id FROM jtf_rs_resource_extns emp, fnd_user users WHERE
691 emp.source_id = users.employee_id and
692 users.user_id = l_user_id;
693
694 CURSOR sel_prev_owner_id IS
695 SELECT resource_id from jtf_rs_resource_extns emp WHERE
696 source_id = l_prev_owner_id;
697
698
699 l_party_role_group_code cs_party_role_group_maps.party_role_group_code%TYPE;
700 l_part_role_code cs_party_role_group_maps.party_role_code%TYPE;
701 l_notify_party_role_list varchar2(4000);
702 l_notify_party_role_relsr_list varchar2(4000);
703
704 CURSOR sel_party_role_csr IS
705 SELECT party_role_code
706 FROM cs_party_role_group_maps
707 WHERE party_role_group_code = l_party_role_group_code
708 AND trunc(sysdate) between trunc(nvl(start_date_active,sysdate))
709 and trunc(nvl(end_date_active,sysdate));
710
711 sel_party_role_rec sel_party_role_csr%ROWTYPE;
712
713 BEGIN
714
715 IF (funmode = 'RUN') THEN
716
717 l_request_number := WF_ENGINE.GetItemAttrText(
718 itemtype => itemtype,
719 itemkey => itemkey,
720 aname => 'REQUEST_NUMBER' );
721
722
723 l_event_name := WF_ENGINE.GetItemAttrText(
724 itemtype => itemtype,
725 itemkey => itemkey,
726 aname => 'EVENTNAME' );
727
728 l_event_condition_id := WF_ENGINE.GetItemAttrNumber(
729 itemtype => itemtype,
730 itemkey => itemkey,
731 aname => 'NTFY_EVENT_CONDITION_ID' );
732
733 l_action_code := WF_ENGINE.GetItemAttrText(
734 itemtype => itemtype,
735 itemkey => itemkey,
736 aname => 'NTFY_ACTION_CODE' );
737
738
739 /***********
740
741 SELECT INCIDENT_ID
742 INTO l_request_id
743 FROM cs_incidents_all_b
744 WHERE INCIDENT_NUMBER = l_request_number;
745 *************/
746
747 l_request_id := WF_ENGINE.GetItemAttrNumber(
748 itemtype => itemtype,
749 itemkey => itemkey,
750 aname => 'REQUEST_ID' );
751
752
753 /*
754 Roopa - begin - bug fix for 2788741
755 */
756 l_user_id := WF_ENGINE.GetItemAttrNumber(
757 itemtype => itemtype,
758 itemkey => itemkey,
759 aname => 'USER_ID' );
760 l_prev_owner_id := WF_ENGINE.GetItemAttrNumber(
761 itemtype => itemtype,
762 itemkey => itemkey,
763 aname => 'PREV_OWNER_ID' );
764
765 OPEN sel_resource_id;
766 FETCH sel_resource_id into l_resource_id;
767 CLOSE sel_resource_id;
768
769 IF (l_action_code = 'NOTIFY_OWNER' OR l_action_code = 'NOTIFY_NEW_OWNER') THEN
770 OPEN sel_inc_owner_id;
771 FETCH sel_inc_owner_id into l_incident_owner_id;
772 CLOSE sel_inc_owner_id;
773 ELSIF (l_action_code = 'NOTIFY_OLD_OWNER') THEN
774 OPEN sel_prev_owner_id;
775 FETCH sel_prev_owner_id into l_incident_owner_id;
776 CLOSE sel_prev_owner_id;
777 END IF;
778
779 IF(l_resource_id = l_incident_owner_id) THEN
780 result := 'COMPLETE:N';
781 return;
782 END IF;
783
784 /*
785 Roopa - end - bug fix for 2788741
786 */
787
788
789 OPEN sel_event_action_csr;
790 FETCH sel_event_action_csr
791 INTO sel_event_action_rec;
792 CLOSE sel_event_action_csr;
793
794 -- Set the message template to be used for the notification
795 WF_ENGINE.SetItemAttrText(
796 itemtype => itemtype,
797 itemkey => itemkey,
798 aname => 'NTFY_MESSAGE_NAME',
799 avalue => sel_event_action_rec.notification_template_id );
800
801
802 /*** Rule 5: Notify service request owner, when the status of a service request ***/
803 /*** he/she owns, is changed. ***/
804 /*** Rule 8 : Notify the owners of related service requests when the current ***/
805 /*** service request's status is changed to a specified value ***/
806
807 IF (sel_event_action_rec.from_to_status_code IS NOT NULL) THEN
808
809 IF (sel_event_action_rec.from_to_status_code = 'STATUS_CHANGED_TO') THEN
810 l_request_status := WF_ENGINE.GetItemAttrText(
811 itemtype => itemtype,
812 itemkey => itemkey,
813 aname => 'REQUEST_STATUS' );
814 ELSIF (sel_event_action_rec.from_to_status_code = 'STATUS_CHANGED_FROM') THEN
815 l_request_status := WF_ENGINE.GetItemAttrText(
816 itemtype => itemtype,
817 itemkey => itemkey,
818 aname => 'REQUEST_STATUS_OLD' );
819 END IF;
820
821 SELECT name
822 INTO l_request_status_temp
823 FROM CS_INCIDENT_STATUSES_VL
824 WHERE INCIDENT_STATUS_ID = sel_event_action_rec.trigger_incident_status_id;
825
826 IF (l_request_status_temp = l_request_status) THEN
827
828 IF (sel_event_action_rec.detail_link_type IS NOT NULL) THEN
829 l_relationship_type_id := sel_event_action_rec.detail_link_type;
830 OPEN sel_link_csr_2;
831 ELSE
832 OPEN sel_link_csr_1;
833 END IF;
834
835 /**************************************
836 Loop through all the related service requests that satisfy
837 the notification rule being processed, and build a list
838 of service requests whose owners we will each then notify
839 ****************************************/
840 LOOP
841 IF (sel_event_action_rec.detail_link_type IS NOT NULL) THEN
842 FETCH sel_link_csr_2 INTO sel_link_rec;
843 EXIT WHEN sel_link_csr_2%NOTFOUND;
844 ELSE
845 FETCH sel_link_csr_1 INTO sel_link_rec;
846 EXIT WHEN sel_link_csr_1%NOTFOUND;
847 END IF;
848
849 l_char_subject_id := TO_CHAR(sel_link_rec.object_id);
850
851 IF ((nvl(LENGTH(l_linked_subject_list), 0) +
852 nvl(LENGTH(l_char_subject_id), 0) + 1) <= 4000) THEN
853
854 IF l_linked_subject_list IS NULL THEN
855 l_linked_subject_list := l_char_subject_id;
856
857 ELSE
858 l_linked_subject_list := l_linked_subject_list || ' ' || l_char_subject_id;
859 END IF;
860 ELSE
861 /*************************************
862 Will need to build another list later since it
863 won't fit here. This flag will tell us later to
864 re-query the remainding subject IDs.
865 **************************************/
866
867 WF_ENGINE.SetItemAttrText(
868 itemtype => itemtype,
869 itemkey => itemkey,
870 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST',
871 avalue => 'Y' );
872 EXIT;
873 END IF;
874 END LOOP;
875
876 IF sel_link_csr_2%ISOPEN THEN
877 CLOSE sel_link_csr_2;
878 ELSIF sel_link_csr_1%ISOPEN THEN
879 CLOSE sel_link_csr_1;
880 END IF;
881
882 IF (l_linked_subject_list IS NOT NULL) THEN
883
884 WF_ENGINE.SetItemAttrText(
885 itemtype => itemtype,
886 itemkey => itemkey,
887 aname => 'NTFY_LINKED_SUBJECT_LIST',
888 avalue => l_linked_subject_list );
889
890 result := 'COMPLETE:Y';
891 ELSE
892
893 -- Roopa - there might be a scenario where SR_STATUS_CHANGED event is associated
894 -- with an action that does not include link/rel type as an action detail
895 -- example : SR_STATUS_CHANGED(event) + NOTIFY_OWNER(action) combination
896 -- the above example is a valid event-action combination. Hence result = 'Y'
897
898 IF(sel_event_action_rec.detail_link_type IS NULL) THEN
899 result := 'COMPLETE:Y';
900 ELSE
901 result := 'COMPLETE:N';
902 END IF;
903
904 END IF;
905
906 IF (sel_event_action_rec.action_code = 'NOTIFY_ASSOCIATED_PARTIES' OR
907 sel_event_action_rec.action_code = 'NOTIFY_ALL_ASSOCIATED_PARTIES' ) THEN
908
909 Create_Role_List
910 ( p_itemtype => itemtype,
911 p_itemkey => itemkey,
912 p_actid => actid,
913 p_funmode => funmode,
914 p_action_code => sel_event_action_rec.action_code,
915 p_role_group_type => sel_event_action_rec.role_group_type,
916 p_role_group_code => sel_event_action_rec.role_group_code) ;
917
918 END IF ;
919
920 ELSE
921 result := 'COMPLETE:N';
922
923 END IF; /**** IF (l_request_status_temp = l_request_status) ******/
924
925 /*** Rule 6: Notify the service request owner, when a link type is created ***/
926 /*** between the current service request to another service request ***/
927 /*** Rule 7 : Notify the service request owner, when a link type is deleted***/
928 /*** between the current service request to another service request ***/
929
930 /*** IF (sel_event_action_rec.from_to_status_code IS NOT NULL) ***/
931
932 ELSIF (sel_event_action_rec.trigger_link_type IS NOT NULL) THEN
933
934 /********************
935 This section is for relationship created/deleted events
936 ********************/
937 l_trigger_link_type := WF_ENGINE.GetItemAttrText(
938 itemtype => itemtype,
939 itemkey => itemkey,
940 aname => 'NTFY_LINK_TYPE');
941
942 -- Obtain link_type_id from the link type name
943 OPEN sel_link_type_id_csr;
944 FETCH sel_link_type_id_csr
945 INTO l_trigger_link_type_id;
946
947 IF (sel_link_type_id_csr%FOUND) THEN
948 -- LINKED_INCIDENT_ID is mandatory for this rule since we can't get a
949 -- handle of the linked SR when the link has been deleted.
950 l_linked_incident_number := WF_ENGINE.GetItemAttrText(
951 itemtype => itemtype,
952 itemkey => itemkey,
953 aname => 'NTFY_LINKED_INCIDENT_NUMBER' );
954
955 IF (sel_event_action_rec.trigger_link_type = l_trigger_link_type_id) THEN
956 result := 'COMPLETE:Y';
957 ELSE
958 result := 'COMPLETE:N';
959 END IF;
960
961 ELSE
962 result := 'COMPLETE:N';
963 END IF;
964 CLOSE sel_link_type_id_csr;
965
966 ELSE /** IF (sel_event_action_rec.from_to_status_code IS NOT NULL) **/
967
968 IF (sel_event_action_rec.action_code = 'NOTIFY_ASSOCIATED_PARTIES' OR
969 sel_event_action_rec.action_code = 'NOTIFY_ALL_ASSOCIATED_PARTIES' ) THEN
970
971 Create_Role_List
972 ( p_itemtype => itemtype,
973 p_itemkey => itemkey,
974 p_actid => actid,
975 p_funmode => funmode,
976 p_action_code => sel_event_action_rec.action_code,
977 p_role_group_type => sel_event_action_rec.role_group_type,
978 p_role_group_code => sel_event_action_rec.role_group_code);
979
980 END IF ;
981
982 result := 'COMPLETE:Y';
983
984 END IF;
985
986
987 ELSIF (funmode = 'CANCEL') THEN
988 result := 'COMPLETE';
989 END IF;
990
991 EXCEPTION
992 WHEN OTHERS THEN
993 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Get_Recipients_To_Notify',
994 itemtype, itemkey, actid, funmode);
995 RAISE;
996
997 END Get_Recipients_To_Notify;
998
999
1000 /**********************************************************************
1001 -- Set_Notification_Details
1002 --
1003 -- This procedure corresponds to the GET_NTFXN_RECIPIENTS function
1004 -- activity.
1005 --
1006 -- This procedure sets all the necessary workflow message attributes
1007 -- that are used to replace the tokens in the message template used
1008 -- for the notification.
1009 -- If the details are set successfully, then the result is set to
1010 -- 'SET', otherwise it is 'UNSET'.
1011 --
1012 -- Modification History:
1013 --
1014 -- Date Name Desc
1015 -- ---------- --------- ---------------------------------------------
1016 -- 04/29/04 RMANABAT Fix for bug 3600819. Regression in functionality
1017 -- of standard workflow Notify activity does not
1018 -- allow users to have multiple email addresses
1019 -- separatde by comma/space. Created one adhoc user
1020 -- for each contact and attaced these to one adhoc
1021 -- role as a list.
1022 -- 05/13/04 RMANABAT Fix for bug 3628552. Use actual workflow users
1023 -- for contacts, if available.
1024 -- 06/09/04 RMANABAT Fix for bug 3663881. Added URL attribute to all
1025 -- ntfxns to contacts. Removed hard code of jsp page
1026 -- in URL.
1027 -- 07/13/04 RMANABAT Fix for bug 3763848. For notification to contacts,
1028 -- create just one ADHOC role and user and re-use
1029 -- updating just the workflow user info.
1030 -- 08/12/04 RMANABAT Fix for bug 3830327. Ntfxn to contacts, duplicate
1031 -- hz_party for the same contact points can exist.
1032 -- This will result in error when attaching the same WF
1033 -- user to an adhoc role. Create adhoc user for duplicate
1034 -- contact WF user.
1035 -- 09/07/04 RMANABAT Fix for bug 3871457. In cursors sel_primary_contact_csr,
1036 -- sel_all_contacts_csr, and sel_all_contacts_csr, changed
1037 -- SELECT null person_id to SELECT to_number(null) person_id.
1038 -- 26-Jul-2005 ANEEMUCH Rel 12.0 changes:
1039 -- 10-Mar-2006 spusegao Modified to set the NTFY_Linked_sr_status and ntfy_linked_sr_summary attrs.
1040 --
1041 -- 14-Mar-2006 spusegao Modified the code to send notification to the primary contacts.
1042 -- to send a notification even if EMAIL is not specified as a primary contact.
1043 -- The new code will derive primary contact in the following sequence.
1044 -- 1. If the primary contact point on the SR is EMAIL itself.
1045 -- 2. If primary contact point is not email then see if email for the primary
1046 -- contact is specified in the CS schema. Derive the email address using it.
1047 -- 3. If email is not specified at all in the CS schema then check if the WF role
1048 -- associated with the primary contact has an email address.
1049 -- 4. If WF role does not have email address then get the primary email address
1050 -- either from HZ or HR depending on the contact type.
1051 -- 5. If primary email address is not specified then use any email address specified
1052 -- This is true only for customer contact.
1053 -- (Bug#5052683)
1054 --
1055 -- 15 Mar 06 spusegao Changed the references to per_people_f in the set_notification_details proc.
1056 -- to use per_workforce_x view.
1057 ***********************************************************************/
1058
1059 PROCEDURE Set_Notification_Details( itemtype IN VARCHAR2,
1060 itemkey IN VARCHAR2,
1061 actid IN NUMBER,
1062 funmode IN VARCHAR2,
1063 result OUT NOCOPY VARCHAR2 ) IS
1064
1065 l_request_number VARCHAR2(64);
1066 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
1067 l_notify_recipient VARCHAR2(100);
1068 l_notification_template_id VARCHAR2(30);
1069 l_linked_subject_list VARCHAR2(4000);
1070 l_element VARCHAR2(100);
1071 l_incident_owner_id cs_incidents_all_b.INCIDENT_OWNER_ID%TYPE;
1072 l_request_id NUMBER;
1073 l_contact_email VARCHAR2(2000);
1074 l_contact_email_list VARCHAR2(2000);
1075 l_contact_point_id NUMBER;
1076 l_contact_point_id_list VARCHAR2(2000);
1077 l_notify_subject_id NUMBER;
1078
1079 l_party_role_code cs_party_role_group_maps.party_role_code%TYPE;
1080 l_party_role_name cs_party_roles_tl.name%TYPE;
1081 l_party_role_group_code cs_party_role_group_maps.party_role_group_code%TYPE;
1082
1083 l_notify_party_role_list VARCHAR2(2000);
1084 l_notify_relsr_party_role_list VARCHAR2(2000);
1085
1086 l_return_status VARCHAR2(1);
1087 l_msg_count NUMBER;
1088 l_msg_data VARCHAR2(2000);
1089 l_owner_role VARCHAR2(320);
1090 l_owner_name VARCHAR2(240);
1091
1092 l_adhoc_role VARCHAR2(100);
1093 l_adhoc_display_name VARCHAR2(360);
1094 l_user VARCHAR2(320);
1095 l_user_display_name VARCHAR2(320);
1096
1097 l_link_type_name VARCHAR2(240);
1098
1099 l_contact_party_id_list VARCHAR2(2000);
1100 l_contact_party_id NUMBER;
1101 l_party_id NUMBER;
1102 l_contact_type VARCHAR2(30);
1103
1104 l_adhoc_user_list VARCHAR2(2000);
1105
1106 l_orig_system VARCHAR2(30);
1107 l_orig_system_id NUMBER;
1108 l_person_id NUMBER;
1109
1110 adhoc_count NUMBER := 0;
1111 l_sr_contact_point_id NUMBER;
1112 l_pri_sr_contact_point_id NUMBER;
1113 l_pri_email_cont_pt_id NUMBER;
1114 l_sr_contact_point_type VARCHAR2(240);
1115 l_contact_first_name VARCHAR2(240);
1116 l_contact_last_name VARCHAR2(240);
1117
1118 -- Local Parameters for html_notifications
1119
1120 l_notification_preference VARCHAR2(240);
1121 l_language VARCHAR2(240);
1122 l_html_notification_flag VARCHAR2(1);
1123 l_event_condition_id NUMBER;
1124 l_html_contact_email_list VARCHAR2(2000);
1125 l_html_adhoc_user_list VARCHAR2(2000);
1126 l_contact_type_list VARCHAR2(2000);
1127 l_contact_id_list VARCHAR2(2000);
1128 l_notification_pref_list VARCHAR2(2000);
1129 l_language_list VARCHAR2(2000);
1130 l_err_code NUMBER;
1131 l_err_str VARCHAR2(2000);
1132
1133
1134 CURSOR sel_primary_contact_csr IS
1135 SELECT hcp.EMAIL_ADDRESS,
1136 cshcp.party_id,
1137 to_number(NULL) person_id,
1138 cshcp.contact_type,
1139 cshcp.sr_contact_point_id
1140 FROM hz_contact_points hcp,
1141 cs_hz_sr_contact_points cshcp
1142 WHERE cshcp.INCIDENT_ID = l_request_id
1143 AND cshcp.PRIMARY_FLAG = 'Y'
1144 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1145 AND hcp.CONTACT_POINT_ID = cshcp.CONTACT_POINT_ID
1146 AND cshcp.contact_type <> 'EMPLOYEE'
1147 AND cshcp.party_role_code = 'CONTACT'
1148 union
1149 select ppf.email_address,
1150 ppf.party_id,
1151 ppf.person_id,
1152 cshcp.contact_type,
1153 cshcp.sr_contact_point_id
1154 from per_all_people_f ppf,
1155 cs_hz_sr_contact_points cshcp
1156 where cshcp.INCIDENT_ID = l_request_id
1157 AND cshcp.PRIMARY_FLAG = 'Y'
1158 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1159 AND ppf.person_id = cshcp.party_id
1160 AND cshcp.contact_type = 'EMPLOYEE'
1161 AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(ppf.effective_start_date, SYSDATE))
1162 AND TRUNC(NVL(ppf.effective_end_date, SYSDATE));
1163
1164 -- Breaking the primary contact cursor
1165
1166 -- Get the primary contact info.
1167
1168 CURSOR get_primary_contact_info IS
1169 SELECT cshcp.party_id,
1170 cshcp.contact_type,
1171 cshcp.sr_contact_point_id,
1172 cshcp.contact_point_type,
1173 cshcp.contact_point_id
1174 FROM cs_hz_sr_contact_points cshcp
1175 WHERE cshcp.INCIDENT_ID = l_request_id
1176 AND cshcp.PRIMARY_FLAG = 'Y'
1177 AND cshcp.party_role_code = 'CONTACT';
1178
1179 -- Get the primary contact's email information from the cs_hz_sr_contact_points table.
1180
1181 CURSOR get_primary_email_info_CS (p_party_id IN NUMBER) IS
1182 SELECT cshcp.sr_contact_point_id,
1183 cshcp.contact_point_id
1184 FROM cs_hz_sr_contact_points cshcp
1185 WHERE cshcp.INCIDENT_ID = l_request_id
1186 AND cshcp.party_role_code = 'CONTACT'
1187 AND cshcp.contact_point_type = 'EMAIL'
1188 AND cshcp.party_id = p_party_id ;
1189
1190 -- Get the email information from the HZ schema for the primary contact.
1191
1192 CURSOR get_primary_email_info_HZ(p_contact_point_id IN NUMBER,
1193 p_party_id IN NUMBER) IS
1194 SELECT email_address
1195 FROM hz_contact_points
1196 WHERE contact_point_id = p_contact_point_id
1197 AND contact_point_type = 'EMAIL'
1198 AND owner_table_name = 'HZ_PARTIES'
1199 AND owner_table_id = p_party_id ;
1200
1201 -- Get any customer email address starting with the primary email address.
1202
1203 CURSOR get_any_cust_email_address(p_party_id IN NUMBER) IS
1204 SELECT email_address
1205 FROM hz_contact_points
1206 WHERE contact_point_type = 'EMAIL'
1207 AND owner_table_name = 'HZ_PARTIES'
1208 AND owner_table_id = p_party_id
1209 ORDER BY Primary_flag DESC;
1210
1211 -- Get the email information from the HR schema for the primary contact.
1212
1213 CURSOR get_primary_email_info_HR(p_person_id IN NUMBER) IS
1214 SELECT ppf.email_address
1215 --ppf.party_id,
1216 --ppf.person_id
1217 FROM per_workforce_x ppf
1218 WHERE ppf.person_id = p_person_id;
1219 --AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(ppf.effective_start_date, SYSDATE))
1220 --AND TRUNC(NVL(ppf.effective_end_date, SYSDATE));
1221
1222 -- Get primary contact party info
1223
1224 CURSOR get_prim_cont_party_info_reln (p_party_id IN NUMBER) IS
1225 SELECT hzp.person_first_name first_name,
1226 hzp.person_last_name last_name
1227 FROM hz_parties hzp,
1228 hz_relationships hzr
1229 WHERE hzr.PARTY_ID = p_party_id
1230 AND hzr.SUBJECT_ID = hzp.PARTY_ID
1231 AND hzr.SUBJECT_TYPE = 'PERSON';
1232
1233 CURSOR get_prim_cont_party_info_per (p_party_id IN NUMBER) IS
1234 SELECT hzp.person_first_name first_name,
1235 hzp.person_last_name last_name
1236 FROM hz_parties hzp
1237 WHERE hzp.PARTY_ID = p_party_id;
1238
1239 CURSOR get_prim_cont_party_info_empl (p_party_id IN NUMBER) IS
1240 SELECT ppf.first_name first_name,
1241 ppf.last_name last_name
1242 FROM per_workforce_x ppf
1243 WHERE ppf.person_id = p_party_id;
1244
1245 --Added and condition for party role in R12 ... aneemuch
1246
1247 CURSOR sel_all_contacts_csr IS
1248 SELECT hcp.EMAIL_ADDRESS,
1249 cshcp.party_id,
1250 to_number(NULL) person_id,
1251 cshcp.contact_type,
1252 cshcp.sr_contact_point_id
1253 FROM hz_contact_points hcp,
1254 cs_hz_sr_contact_points cshcp
1255 WHERE cshcp.INCIDENT_ID = l_request_id
1256 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1257 AND hcp.CONTACT_POINT_ID = cshcp.CONTACT_POINT_ID
1258 AND cshcp.contact_type <> 'EMPLOYEE'
1259 AND cshcp.party_role_code = 'CONTACT'
1260 UNION
1261 select ppf.email_address,
1262 ppf.party_id,
1263 ppf.person_id,
1264 cshcp.contact_type,
1265 cshcp.sr_contact_point_id
1266 from per_all_people_f ppf,
1267 cs_hz_sr_contact_points cshcp
1268 where cshcp.INCIDENT_ID = l_request_id
1269 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1270 AND ppf.person_id = cshcp.party_id
1271 AND cshcp.contact_type = 'EMPLOYEE'
1272 AND cshcp.party_role_code = 'CONTACT'
1273 AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(ppf.effective_start_date, SYSDATE))
1274 AND TRUNC(NVL(ppf.effective_end_date, SYSDATE));
1275 --Added and condition for party role in R12 ... aneemuch
1276
1277
1278 -- Rel 12.0 changes
1279 -- Cursor to query contacts from cs_hz_sr_contact_points table for notification to be
1280 -- sent to all the contacts of a particular party role code.
1281
1282 CURSOR sel_party_role_contacts_csr IS
1283 SELECT hcp.EMAIL_ADDRESS,
1284 cshcp.party_id,
1285 to_number(NULL) person_id,
1286 cshcp.contact_type,
1287 cshcp.sr_contact_point_id
1288 FROM hz_contact_points hcp,
1289 cs_hz_sr_contact_points cshcp
1290 WHERE cshcp.INCIDENT_ID = l_request_id
1291 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1292 AND hcp.CONTACT_POINT_ID = cshcp.CONTACT_POINT_ID
1293 AND cshcp.contact_type <> 'EMPLOYEE'
1294 AND cshcp.party_role_code = l_party_role_code
1295 UNION
1296 select ppf.email_address,
1297 ppf.party_id,
1298 ppf.person_id,
1299 cshcp.contact_type,
1300 cshcp.sr_contact_point_id
1301 from per_all_people_f ppf,
1302 cs_hz_sr_contact_points cshcp
1303 where cshcp.INCIDENT_ID = l_request_id
1304 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1305 AND ppf.person_id = cshcp.party_id
1306 AND cshcp.contact_type = 'EMPLOYEE'
1307 AND cshcp.party_role_code = l_party_role_code
1308 AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(ppf.effective_start_date, SYSDATE))
1309 AND TRUNC(NVL(ppf.effective_end_date, SYSDATE));
1310
1311 --Added and condition for party role in R12 ... aneemuch
1312
1313
1314 CURSOR sel_new_contact_csr IS
1315 SELECT hcp.EMAIL_ADDRESS,
1316 cshcp.party_id,
1317 to_number(NULL) person_id,
1318 cshcp.contact_type,
1319 cshcp.sr_contact_point_id
1320 FROM hz_contact_points hcp,
1321 cs_hz_sr_contact_points cshcp
1322 WHERE
1323 hcp.CONTACT_POINT_TYPE = 'EMAIL'
1324 AND hcp.CONTACT_POINT_ID = l_contact_point_id
1325 AND hcp.CONTACT_POINT_ID = cshcp.CONTACT_POINT_ID
1326 AND cshcp.contact_type <> 'EMPLOYEE'
1327 AND cshcp.party_role_code = 'CONTACT'
1328 UNION
1329 SELECT ppf.EMAIL_ADDRESS,
1330 ppf.party_id,
1331 ppf.person_id,
1332 cshcp.contact_type,
1333 cshcp.sr_contact_point_id
1334 FROM per_all_people_f ppf,
1335 cs_hz_sr_contact_points cshcp
1336 WHERE
1337 cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1338 AND ppf.PERSON_ID = l_contact_point_id
1339 AND cshcp.PARTY_ID = ppf.person_id
1340 AND cshcp.contact_type = 'EMPLOYEE'
1341 AND cshcp.party_role_code = 'CONTACT'
1342 AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(ppf.effective_start_date, SYSDATE))
1343 AND TRUNC(NVL(ppf.effective_end_date, SYSDATE));
1344
1345 CURSOR sel_new_party_role_contact_csr IS
1346 SELECT hcp.EMAIL_ADDRESS,
1347 cshcp.party_id,
1348 to_number(NULL) person_id,
1349 cshcp.contact_type,
1350 cshcp.sr_contact_point_id,
1351 cpr.name,
1352 cpr.party_role_code
1353 FROM hz_contact_points hcp,
1354 cs_hz_sr_contact_points cshcp,
1355 cs_party_roles_tl cpr
1356 WHERE
1357 hcp.CONTACT_POINT_TYPE = 'EMAIL'
1358 AND hcp.CONTACT_POINT_ID = l_contact_point_id
1359 AND hcp.CONTACT_POINT_ID = cshcp.CONTACT_POINT_ID
1360 AND cshcp.party_role_code = cpr.party_role_code
1361 AND cpr.language = userenv('LANG')
1362 AND cshcp.contact_type <> 'EMPLOYEE'
1363 AND cshcp.party_role_code <> 'CONTACT'
1364 UNION
1365 SELECT ppf.EMAIL_ADDRESS,
1366 ppf.party_id,
1367 ppf.person_id,
1368 cshcp.contact_type,
1369 cshcp.sr_contact_point_id,
1370 cpr.name,
1371 cpr.party_role_code
1372 FROM per_all_people_f ppf,
1373 cs_hz_sr_contact_points cshcp,
1374 cs_party_roles_tl cpr
1375 WHERE
1376 cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1377 AND ppf.PERSON_ID = l_contact_point_id
1378 AND cshcp.PARTY_ID = ppf.person_id
1379 AND cshcp.contact_type = 'EMPLOYEE'
1380 AND cshcp.party_role_code = cpr.party_role_code
1381 AND cpr.language = userenv('LANG')
1382 AND cshcp.party_role_code <> 'CONTACT'
1383 AND TRUNC(SYSDATE) BETWEEN TRUNC(NVL(ppf.effective_start_date, SYSDATE))
1384 AND TRUNC(NVL(ppf.effective_end_date, SYSDATE));
1385
1386 CURSOR sel_link_csr IS
1387 SELECT
1388 inc.incident_number,
1389 inc.incident_owner_id,
1390 cil.object_id,
1391 cil.link_type_id,
1392 cilt.name link_type_name
1393 FROM cs_incident_links cil,
1394 cs_incidents_all_b inc,
1395 CS_SR_LINK_TYPES_VL cilt
1396 WHERE cil.subject_id = l_request_id
1397 and cil.object_id = l_notify_subject_id
1398 and inc.incident_id = cil.object_id
1399 and cilt.link_type_id(+) = cil.link_type_id;
1400
1401 sel_link_rec sel_link_csr%ROWTYPE;
1402
1403 /*
1404 Roopa - bug fix for 2788741
1405 For the following action:
1406 NOTIFY_OWNER_OF_RELATED_SR
1407
1408 This activity returns N (to skip notify action) if for the above actions, the SR owner
1409 himself has updated the SR
1410 */
1411 l_incident_owner_id NUMBER;
1412 l_resource_id NUMBER;
1413 l_user_id NUMBER;
1414
1415 CURSOR sel_resource_id IS
1416 SELECT resource_id FROM jtf_rs_resource_extns emp, fnd_user users WHERE
1417 emp.source_id = users.employee_id and
1418 users.user_id = l_user_id;
1419
1420 /* Roopa - begin
1421 Fix for bug # 2788156
1422 The wf role should be checked on the employee/source id and NOT on the incident_owner_id
1423 This cursor will get us the employee id
1424 */
1425
1426 CURSOR l_sel_employee_id_csr IS
1427 SELECT source_id FROM jtf_rs_resource_extns emp
1428 WHERE emp.resource_id = sel_link_rec.incident_owner_id;
1429
1430 l_employee_id NUMBER;
1431
1432 CURSOR l_sel_curr_sr_details_csr IS
1433 SELECT incident_type_id,incident_status_id,incident_urgency_id,incident_severity_id,summary
1434 FROM cs_incidents_all_vl inc
1435 WHERE inc.incident_number = l_request_number;
1436
1437 l_sel_curr_sr_details_rec l_sel_curr_sr_details_csr%ROWTYPE;
1438
1439 l_prev_type_id NUMBER;
1440 l_prev_status_id NUMBER;
1441 l_prev_severity_id NUMBER;
1442 l_prev_urgency_id NUMBER;
1443 l_prev_summary VARCHAR2(240);
1444
1445 l_lookup_code VARCHAR2(30);
1446 l_changed_field VARCHAR2(30);
1447 l_changed_field_list VARCHAR2(240);
1448 l_updated_by VARCHAR2(240);
1449
1450
1451 CURSOR l_sel_lookup_value_csr IS
1452 SELECT a.lookup_code, a.meaning FROM cs_lookups a
1453 WHERE a.lookup_type = 'CS_SR_UPDATED_FIELDS';
1454
1455 l_sel_lookup_value_rec l_sel_lookup_value_csr%ROWTYPE;
1456
1457
1458 CURSOR l_get_resource_name_csr IS
1459 SELECT source_last_name,source_first_name
1460 from jtf_rs_resource_extns a, fnd_user b, cs_incidents_all_b c
1461 WHERE c.last_updated_by = b.user_id and
1462 b.employee_id = a.source_id and
1463 c.incident_number = l_request_number;
1464
1465 l_get_resource_name_rec l_get_resource_name_csr%ROWTYPE;
1466
1467 CURSOR l_get_create_rsrc_csr IS
1468 SELECT source_last_name,source_first_name
1469 from jtf_rs_resource_extns a, fnd_user b, cs_incidents_all_b c
1470 WHERE c.created_by = b.user_id and
1471 b.employee_id = a.source_id and
1472 c.incident_number = l_request_number;
1473
1474 l_get_create_rsrc_rec l_get_create_rsrc_csr%ROWTYPE;
1475
1476 l_created_by VARCHAR2(240);
1477
1478 l_solution_number VARCHAR2(30);
1479 l_solution_summary VARCHAR2(500);
1480
1481 CURSOR l_getsoln_summary_csr IS
1482 SELECT name from CS_KB_SETS_VL
1483 WHERE set_number = l_solution_number
1484 and status='PUB';
1485
1486 /* ROOPA - 11/12/03 */
1487 l_request_id_temp NUMBER;
1488 l_notify_contact_name VARCHAR2(200);
1489 l_serviceRequest_URL VARCHAR2(200);
1490
1491 -- The following cursor is needed to fill in the 3 NEW WF item attributes:
1492 -- 1. NTFY_LINKED_SR_STATUS
1493 -- 2. NTFY_LINKED_SR_SUMMARY
1494 -- 3. NTFY_LINK_TYPE
1495 CURSOR sel_linked_sr_details_csr IS
1496 SELECT a.summary, b.name
1497 FROM cs_incidents_all_vl a,
1498 cs_incident_statuses_vl b
1499 WHERE a.incident_status_id = b.incident_status_id AND
1500 a.incident_id = l_request_id;
1501
1502 sel_linked_sr_details_rec sel_linked_sr_details_csr%ROWTYPE;
1503
1504 -- The following cursor is needed to fill in the 1 NEW WF item attributes:
1505 -- 1. NTFY_LINK_TYPE
1506 CURSOR sel_linked_sr_type_csr IS
1507 SELECT cilt.name link_type_name
1508 FROM cs_incident_links cil,
1509 CS_SR_LINK_TYPES_VL cilt
1510 WHERE cilt.link_type_id = cil.link_type_id AND
1511 cil.subject_id = l_notify_subject_id AND
1512 cil.object_id = l_request_id;
1513
1514 sel_linked_sr_type_rec sel_linked_sr_type_csr%ROWTYPE;
1515
1516
1517
1518 -- The following cursor is needed to derive the contact's name.
1519 -- At the point of opening this cursor, we already have the contact point id.
1520 -- We use this contact point id to go against the following 2 tables to derive the
1521 -- contact's full name :
1522 -- 1) PER_ALL_PEOPLE_F - for contact type = EMPLOYEE
1523 -- 2) HZ_RELATIONSHIPS - for contact type = PARTY_RELATIONSHIP
1524 -- 3) HZ_PARTIES - for contact type = PERSON
1525
1526 l_tmp_contact_point_id NUMBER;
1527
1528 CURSOR sel_contact_name_csr IS
1529 SELECT hzp.person_first_name first_name,
1530 hzp.person_last_name last_name,
1531 cshcp.contact_type,
1532 cshcp.contact_point_id
1533 FROM hz_parties hzp,
1534 hz_relationships hzr,
1535 cs_hz_sr_contact_points cshcp
1536 WHERE cshcp.INCIDENT_ID = l_request_id
1537 AND cshcp.sr_contact_point_id = l_tmp_contact_point_id
1538 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1539 AND cshcp.contact_type = 'PARTY_RELATIONSHIP'
1540 AND cshcp.PARTY_ID = hzr.PARTY_ID
1541 AND hzr.SUBJECT_ID = hzp.PARTY_ID
1542 AND hzr.SUBJECT_TYPE = 'PERSON'
1543 UNION
1544 SELECT hzp.person_first_name first_name,
1545 hzp.person_last_name last_name,
1546 cshcp.contact_type,
1547 cshcp.contact_point_id
1548 FROM hz_parties hzp,
1549 cs_hz_sr_contact_points cshcp
1550 WHERE cshcp.INCIDENT_ID = l_request_id
1551 AND cshcp.sr_contact_point_id = l_tmp_contact_point_id
1552 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1553 AND cshcp.contact_type = 'PERSON'
1554 AND cshcp.PARTY_ID = hzp.PARTY_ID
1555 UNION
1556 SELECT ppf.first_name first_name,
1557 ppf.last_name last_name,
1558 cshcp.contact_type,
1559 cshcp.contact_point_id
1560 FROM per_all_people_f ppf,
1561 cs_hz_sr_contact_points cshcp
1562 WHERE cshcp.INCIDENT_ID = l_request_id
1563 AND cshcp.sr_contact_point_id = l_tmp_contact_point_id
1564 AND cshcp.CONTACT_POINT_TYPE = 'EMAIL'
1565 AND cshcp.contact_type = 'EMPLOYEE'
1566 AND cshcp.PARTY_ID = ppf.PERSON_ID;
1567
1568 sel_contact_name_rec sel_contact_name_csr%ROWTYPE;
1569
1570 l_temp_contact_id_list VARCHAR2(2000);
1571 l_temp_item_key VARCHAR2(100);
1572
1573 CURSOR check_if_item_attr_exists_csr IS
1574 select text_value from wf_item_attribute_values
1575 where item_type='SERVEREQ'
1576 and name = 'CONTACT_PARTY_ID_LIST'
1577 and item_key = l_temp_item_key;
1578
1579
1580 -- There probably is an api to obtain the jsp name given the function,
1581 -- we can replace this cursor with that api when we find out.
1582 CURSOR sel_jsp_name_csr IS
1583 select WEB_HTML_CALL from fnd_form_functions
1584 where FUNCTION_NAME='IBU_SR_DETAILS';
1585 l_jsp_name VARCHAR2(240);
1586
1587 --
1588 /* End ROOPA - 11/12/03 */
1589
1590 CURSOR c_user(p_orig_system IN VARCHAR2, p_orig_system_id IN NUMBER) IS
1591 select name,
1592 substrb(display_name,1,360),
1593 email_address,
1594 notification_preference,
1595 language
1596 from wf_users
1597 where orig_system = p_orig_system
1598 and orig_system_id = p_orig_system_id
1599 order by status, start_date;
1600 l_email_address VARCHAR2(320);
1601
1602
1603 CURSOR c_party_role_csr (p_party_role_code in VARCHAR2) IS
1604 SELECT name
1605 FROM cs_party_roles_vl
1606 WHERE party_role_code = p_party_role_code;
1607
1608 -- Cursor to check if the HTML notification is required.
1609
1610 CURSOR c_check_html_notification IS
1611 SELECT NVL(html_notification,'N')
1612 FROM cs_sr_action_details
1613 WHERE event_condition_id = l_event_condition_id
1614 AND action_code = l_action_code ;
1615
1616
1617 BEGIN
1618
1619 IF (funmode = 'RUN') THEN
1620
1621 l_temp_item_key := itemkey;
1622
1623 l_action_code := WF_ENGINE.GetItemAttrText(
1624 itemtype => itemtype,
1625 itemkey => itemkey,
1626 aname => 'NTFY_ACTION_CODE' );
1627
1628 l_event_condition_id := WF_ENGINE.GetItemAttrText(
1629 itemtype => itemtype,
1630 itemkey => itemkey,
1631 aname => 'NTFY_EVENT_CONDITION_ID' );
1632
1633 l_request_number := WF_ENGINE.GetItemAttrText(
1634 itemtype => itemtype,
1635 itemkey => itemkey,
1636 aname => 'REQUEST_NUMBER' );
1637
1638 l_request_id := WF_ENGINE.GetItemAttrNumber(
1639 itemtype => itemtype,
1640 itemkey => itemkey,
1641 aname => 'REQUEST_ID' );
1642
1643 /* Roopa - begin
1644 Fix for bug # 2809232
1645 */
1646 OPEN l_sel_curr_sr_details_csr;
1647 FETCH l_sel_curr_sr_details_csr into l_sel_curr_sr_details_rec;
1648 CLOSE l_sel_curr_sr_details_csr;
1649
1650 l_prev_type_id := WF_ENGINE.GetItemAttrText(
1651 itemtype => itemtype,
1652 itemkey => itemkey,
1653 aname => 'PREV_TYPE_ID' );
1654
1655 l_prev_status_id := WF_ENGINE.GetItemAttrText(
1656 itemtype => itemtype,
1657 itemkey => itemkey,
1658 aname => 'PREV_STATUS_ID' );
1659
1660 l_prev_severity_id := WF_ENGINE.GetItemAttrText(
1661 itemtype => itemtype,
1662 itemkey => itemkey,
1663 aname => 'PREV_SEVERITY_ID' );
1664 l_prev_urgency_id := WF_ENGINE.GetItemAttrText(
1665 itemtype => itemtype,
1666 itemkey => itemkey,
1667 aname => 'PREV_URGENCY_ID' );
1668
1669
1670 l_prev_summary := WF_ENGINE.GetItemAttrText(
1671 itemtype => itemtype,
1672 itemkey => itemkey,
1673 aname => 'PREV_SUMMARY' );
1674
1675
1676
1677
1678 /****************************
1679 create a list of SR attributes that were updated, which will later
1680 be included in the ntfxn message text.
1681 ****************************/
1682
1683 FOR i in l_sel_lookup_value_csr LOOP
1684 IF(i.lookup_code = 'CS_SR_SEVERITY') THEN
1685 IF(l_prev_severity_id <> l_sel_curr_sr_details_rec.incident_severity_id) THEN
1686 l_changed_field := i.meaning;
1687 ELSE
1688 l_changed_field := null;
1689 END IF;
1690 ELSIF (i.lookup_code = 'CS_SR_STATUS') THEN
1691 IF(l_prev_status_id <> l_sel_curr_sr_details_rec.incident_status_id) THEN
1692 l_changed_field := i.meaning;
1693 ELSE
1694 l_changed_field := null;
1695 END IF;
1696 ELSIF (i.lookup_code = 'CS_SR_TYPE') THEN
1697 IF(l_prev_type_id <> l_sel_curr_sr_details_rec.incident_type_id) THEN
1698 l_changed_field := i.meaning;
1699 ELSE
1700 l_changed_field := null;
1701 END IF;
1702 ELSIF (i.lookup_code = 'CS_SR_URGENCY') THEN
1703 IF(l_prev_urgency_id <> l_sel_curr_sr_details_rec.incident_urgency_id) THEN
1704 l_changed_field := i.meaning;
1705 ELSE
1706 l_changed_field := null;
1707 END IF;
1708 ELSIF (i.lookup_code = 'CS_SR_SUMMARY') THEN
1709 IF(l_prev_summary <> l_sel_curr_sr_details_rec.summary) THEN
1710 l_changed_field := i.meaning;
1711 ELSE
1712 l_changed_field := null;
1713 END IF;
1714 END IF;
1715
1716 IF(l_changed_field is not null) THEN
1717 IF (l_changed_field_list is NULL) THEN
1718 l_changed_field_list := l_changed_field;
1719 l_changed_field := null;
1720 ELSE
1721 l_changed_field_list := l_changed_field_list || ',' || l_changed_field;
1722 l_changed_field := null;
1723 END IF;
1724 END IF;
1725
1726 END LOOP;
1727
1728 IF(l_changed_field_list is not null) THEN
1729 l_changed_field_list := l_changed_field_list || ' of ';
1730 WF_ENGINE.SetItemAttrText(
1731 itemtype => itemtype,
1732 itemkey => itemkey,
1733 aname => 'CHANGED_LIST',
1734 avalue => l_changed_field_list );
1735 END IF;
1736
1737 OPEN l_get_resource_name_csr;
1738 FETCH l_get_resource_name_csr INTO l_get_resource_name_rec;
1739 CLOSE l_get_resource_name_csr;
1740
1741 l_updated_by := l_get_resource_name_rec.source_first_name || ' '
1742 || l_get_resource_name_rec.source_last_name;
1743
1744 WF_ENGINE.SetItemAttrText(
1745 itemtype => itemtype,
1746 itemkey => itemkey,
1747 aname => 'UPDATED_BY',
1748 avalue => l_updated_by );
1749
1750 /* Roopa - end
1751 Fix for bug # 2809232
1752 */
1753
1754 /* Roopa - begin
1755 Fix for bug # 2809222
1756 */
1757 OPEN l_get_create_rsrc_csr;
1758 FETCH l_get_create_rsrc_csr INTO l_get_create_rsrc_rec;
1759 CLOSE l_get_create_rsrc_csr;
1760
1761 l_created_by := l_get_resource_name_rec.source_first_name || ' '
1762 || l_get_resource_name_rec.source_last_name;
1763
1764 WF_ENGINE.SetItemAttrText(
1765 itemtype => itemtype,
1766 itemkey => itemkey,
1767 aname => 'CREATED_BY',
1768 avalue => l_created_by );
1769 /* Roopa - end
1770 Fix for bug # 2809222
1771 */
1772
1773
1774 /* Roopa - begin
1775 Fix for bug # 2804495
1776 */
1777 l_solution_number := WF_ENGINE.GetItemAttrText(
1778 itemtype => itemtype,
1779 itemkey => itemkey,
1780 aname => 'SOLUTION_NUMBER');
1781 IF (l_solution_number is not null) THEN
1782 OPEN l_getsoln_summary_csr;
1783 FETCH l_getsoln_summary_csr INTO l_solution_summary;
1784 CLOSE l_getsoln_summary_csr;
1785
1786 IF(l_solution_summary is not null) THEN
1787 WF_ENGINE.SetItemAttrText(
1788 itemtype => itemtype,
1789 itemkey => itemkey,
1790 aname => 'SOLUTION SUMMARY',
1791 avalue => l_solution_summary);
1792
1793 END IF;
1794
1795 END IF;
1796
1797 /* Roopa - end
1798 Fix for bug # 2804495
1799 */
1800
1801
1802 IF (l_action_code = 'NOTIFY_OWNER' OR l_action_code = 'NOTIFY_NEW_OWNER') THEN
1803 l_notify_recipient := WF_ENGINE.GetItemAttrText(
1804 itemtype => itemtype,
1805 itemkey => itemkey,
1806 aname => 'OWNER_ROLE');
1807
1808 ELSIF (l_action_code = 'NOTIFY_OLD_OWNER') THEN
1809 l_notify_recipient := WF_ENGINE.GetItemAttrText(
1810 itemtype => itemtype,
1811 itemkey => itemkey,
1812 aname => 'PREV_OWNER_ROLE');
1813
1814 ELSIF (l_action_code = 'NOTIFY_OWNER_OF_RELATED_SR') THEN
1815 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
1816 itemtype => itemtype,
1817 itemkey => itemkey,
1818 aname => 'NTFY_LINKED_SUBJECT_LIST');
1819 IF (l_linked_subject_list IS NOT NULL) THEN
1820 pull_from_list(itemlist => l_linked_subject_list,
1821 element => l_element);
1822
1823 l_notify_subject_id := TO_NUMBER(l_element);
1824
1825 WF_ENGINE.SetItemAttrText(
1826 itemtype => itemtype,
1827 itemkey => itemkey,
1828 aname => 'NTFY_LINKED_SUBJECT_LIST',
1829 avalue => l_linked_subject_list );
1830
1831 WF_ENGINE.SetItemAttrNumber(
1832 itemtype => itemtype,
1833 itemkey => itemkey,
1834 aname => 'NTFY_SUBJECT_ID',
1835 avalue => l_notify_subject_id );
1836
1837 OPEN sel_link_csr;
1838 FETCH sel_link_csr INTO sel_link_rec;
1839 CLOSE sel_link_csr;
1840
1841
1842 /*
1843 Roopa - begin - bug fix for 2788741
1844 */
1845
1846 l_user_id := WF_ENGINE.GetItemAttrNumber(
1847 itemtype => itemtype,
1848 itemkey => itemkey,
1849 aname => 'USER_ID' );
1850 OPEN sel_resource_id;
1851 FETCH sel_resource_id into l_resource_id;
1852 CLOSE sel_resource_id;
1853
1854 IF(l_resource_id = sel_link_rec.incident_owner_id) THEN
1855
1856 result := 'COMPLETE:UNSET';
1857 return;
1858 END IF;
1859
1860 /*
1861 Roopa - end - bug fix for 2788741
1862 */
1863
1864 WF_ENGINE.SetItemAttrText(
1865 itemtype => itemtype,
1866 itemkey => itemkey,
1867 aname => 'NTFY_LINKED_INCIDENT_NUMBER',
1868 avalue => sel_link_rec.incident_number );
1869
1870 -- Get link Type name from link_type_id
1871
1872 WF_ENGINE.SetItemAttrText(
1873 itemtype => itemtype,
1874 itemkey => itemkey,
1875 aname => 'NTFY_LINK_TYPE',
1876 avalue => sel_link_rec.link_type_name );
1877
1878 /* Roopa - begin
1879 Fix for bug # 2788156
1880 The wf role should be checked on the employee/source id and NOT on the incident_owner_id
1881 This cursor will get us the employee id
1882 */
1883
1884 OPEN l_sel_employee_id_csr;
1885 FETCH l_sel_employee_id_csr into l_employee_id;
1886 CLOSE l_sel_employee_id_csr;
1887
1888 /* Roopa - end
1889 Fix for bug # 2788156
1890 */
1891
1892 IF(l_employee_id is not null) THEN
1893 CS_WORKFLOW_PUB.Get_Employee_Role (
1894 p_api_version => 1.0,
1895 p_return_status => l_return_status,
1896 p_msg_count => l_msg_count,
1897 p_msg_data => l_msg_data,
1898 --p_employee_id => l_incident_owner_id,
1899 p_employee_id => l_employee_id,
1900 p_role_name => l_owner_role,
1901 p_role_display_name => l_owner_name );
1902
1903 IF (l_owner_role IS NOT NULL) THEN
1904 l_notify_recipient := l_owner_role;
1905 END IF;
1906 END iF;
1907
1908 END IF; /*** IF (l_linked_subject_list IS NOT NULL) ***/
1909
1910
1911
1912
1913 /* ROOPA - 11/12/03 */
1914 /* 11.5.10 enhancement - we have added 2 new action codes:
1915 1. NOTIFY_PRIM_CONTACT_OF_REL_SR - notify the prim contact of all related SRs
1916 2. NOTIFY_ALL_CONTACTS_OF_REL_SR - notify all contacts of all related SRs
1917
1918 Facts
1919 ------
1920 1. The above 2 actions are associated only with "Service Request Status Changed" event.
1921
1922 2. If the SR's status changes to/from a particular status AND if the SR has a specified
1923 relationship with it's linked SRs, only then these 2 actions will be executed.
1924
1925 3. NOTIFY_PRIM_CONTACT_OF_REL_SR notifies only the primary contacts of related SRs while
1926 NOTIFY_ALL_CONTACTS_OF_REL_SR notifies all contacts of all related SRs
1927
1928 The following block handles notification rules defined for these 2 actions
1929 */
1930 ELSIF (l_action_code = 'NOTIFY_PRIM_CONTACT_OF_REL_SR') THEN
1931
1932 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
1933 itemtype => itemtype,
1934 itemkey => itemkey,
1935 aname => 'NTFY_LINKED_SUBJECT_LIST');
1936
1937 -- Check if the html_notification flag is set
1938
1939 OPEN c_check_html_notification;
1940 FETCH c_check_html_notification INTO l_html_notification_flag ;
1941 CLOSE c_check_html_notification;
1942
1943 -- LOOP
1944
1945 IF (l_linked_subject_list IS NOT NULL) THEN
1946
1947 pull_from_list(itemlist => l_linked_subject_list,
1948 element => l_element);
1949
1950 l_notify_subject_id := TO_NUMBER(l_element);
1951
1952 WF_ENGINE.SetItemAttrText(
1953 itemtype => itemtype,
1954 itemkey => itemkey,
1955 aname => 'NTFY_LINKED_SUBJECT_LIST',
1956 avalue => l_linked_subject_list );
1957
1958 WF_ENGINE.SetItemAttrNumber(
1959 itemtype => itemtype,
1960 itemkey => itemkey,
1961 aname => 'NTFY_SUBJECT_ID',
1962 avalue => l_notify_subject_id );
1963
1964 OPEN sel_link_csr;
1965 FETCH sel_link_csr INTO sel_link_rec;
1966 CLOSE sel_link_csr;
1967
1968 OPEN sel_linked_sr_type_csr;
1969 FETCH sel_linked_sr_type_csr INTO sel_linked_sr_type_rec;
1970 CLOSE sel_linked_sr_type_csr;
1971
1972
1973 l_user_id := WF_ENGINE.GetItemAttrNumber(
1974 itemtype => itemtype,
1975 itemkey => itemkey,
1976 aname => 'USER_ID' );
1977
1978 WF_ENGINE.SetItemAttrText(
1979 itemtype => itemtype,
1980 itemkey => itemkey,
1981 aname => 'NTFY_LINKED_INCIDENT_NUMBER',
1982 avalue => sel_link_rec.incident_number );
1983
1984
1985 -- Get link Type name from link_type_id
1986
1987 WF_ENGINE.SetItemAttrText(
1988 itemtype => itemtype,
1989 itemkey => itemkey,
1990 aname => 'NTFY_LINK_TYPE',
1991 avalue => sel_linked_sr_type_rec.link_type_name );
1992
1993
1994 l_request_id := l_notify_subject_id;
1995
1996 OPEN sel_linked_sr_details_csr;
1997 FETCH sel_linked_sr_details_csr into sel_linked_sr_details_rec;
1998 CLOSE sel_linked_sr_details_csr;
1999
2000 WF_ENGINE.SetItemAttrText(
2001 itemtype => itemtype,
2002 itemkey => itemkey,
2003 aname => 'NTFY_LINKED_SR_STATUS',
2004 avalue => sel_linked_sr_details_rec.name );
2005
2006 WF_ENGINE.SetItemAttrText(
2007 itemtype => itemtype,
2008 itemkey => itemkey,
2009 aname => 'NTFY_LINKED_SR_SUMMARY',
2010 avalue => sel_linked_sr_details_rec.summary );
2011
2012
2013 OPEN get_primary_contact_info;
2014
2015 LOOP
2016 FETCH get_primary_contact_info
2017 INTO l_contact_party_id,l_contact_type,l_tmp_contact_point_id,l_sr_contact_point_type,l_sr_contact_point_id;
2018 EXIT WHEN get_primary_contact_info%NOTFOUND;
2019
2020 -- get the email address from the CS schema if l_contact_type is not EMAIL.
2021
2022 -- Get primary contact point ID from cs schema
2023
2024 IF l_sr_contact_point_type <> 'EMAIL' THEN
2025
2026 OPEN get_primary_email_info_CS (l_contact_party_id) ;
2027 FETCH get_primary_email_info_CS INTO l_pri_sr_contact_point_id, l_pri_email_cont_pt_id ;
2028 CLOSE get_primary_email_info_CS;
2029
2030 ELSE
2031 l_pri_sr_contact_point_id := l_tmp_contact_point_id;
2032 l_pri_email_cont_pt_id := l_sr_contact_point_id;
2033 END IF ;
2034
2035 -- get the email address if contact point id found in CS schema.
2036
2037 IF l_pri_email_cont_pt_id IS NOT NULL THEN
2038
2039 IF (l_contact_type = 'PERSON' OR l_contact_type = 'PARTY_RELATIONSHIP') THEN
2040
2041 OPEN get_primary_email_info_HZ (l_pri_email_cont_pt_id,l_contact_party_id);
2042 FETCH get_primary_email_info_HZ INTO l_contact_email;
2043 CLOSE get_primary_email_info_HZ;
2044
2045 ELSIF l_contact_type = 'EMPLOYEE' THEN
2046 OPEN get_primary_email_info_HR (l_contact_party_id);
2047 FETCH get_primary_email_info_HR INTO l_contact_email;
2048 CLOSE get_primary_email_info_HR;
2049
2050 END IF;
2051 END IF;
2052
2053 -- This section gets the workflow user of the contact.
2054
2055 IF (l_contact_type = 'EMPLOYEE') THEN
2056 l_orig_system := 'PER';
2057 l_orig_system_id := l_contact_party_id; -- l_person_id;
2058 ELSE
2059 l_orig_system := 'HZ_PARTY';
2060 l_orig_system_id := l_contact_party_id;
2061 END IF;
2062
2063 OPEN c_user(l_orig_system,l_orig_system_id);
2064 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
2065 CLOSE c_user;
2066
2067 IF (l_email_address IS NOT NULL) AND (l_contact_email IS NULL) THEN
2068 l_contact_email := l_email_address;
2069
2070 END IF ;
2071
2072 -- This section finds some email address of customer contact. if email address is not present
2073 -- with the WF role or as a contact point in the CS schama
2074
2075 IF ((l_email_address IS NULL) AND (l_contact_email IS NULL) AND (l_contact_type <> 'EMPLOYEE')) THEN
2076
2077 FOR get_any_cust_email_address_rec IN get_any_cust_email_address(l_contact_party_id)
2078 LOOP
2079 l_contact_email := get_any_cust_email_address_rec.email_address;
2080 EXIT WHEN get_any_cust_email_address%FOUND;
2081 END LOOP;
2082 END IF ;
2083
2084 -- Check for WF email list length not to exceed 2000
2085
2086 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
2087
2088 IF (l_contact_email IS NOT NULL)THEN
2089
2090 IF l_contact_type = 'PERSON' THEN
2091
2092 OPEN get_prim_cont_party_info_per(l_contact_party_id) ;
2093 FETCH get_prim_cont_party_info_per INTO l_contact_first_name , l_contact_last_name;
2094 CLOSE get_prim_cont_party_info_per;
2095
2096 ELSIF l_contact_type = 'PARTY_RELATIONSHIP' THEN
2097
2098 OPEN get_prim_cont_party_info_reln(l_contact_party_id) ;
2099 FETCH get_prim_cont_party_info_reln INTO l_contact_first_name , l_contact_last_name;
2100 CLOSE get_prim_cont_party_info_reln;
2101
2102 ELSIF l_contact_type = 'EMPLOYEE' THEN
2103
2104 OPEN get_prim_cont_party_info_empl(l_contact_party_id) ;
2105 FETCH get_prim_cont_party_info_empl INTO l_contact_first_name , l_contact_last_name;
2106 CLOSE get_prim_cont_party_info_empl;
2107
2108 END IF;
2109
2110 l_notify_contact_name := l_contact_first_name|| ' ' ||l_contact_last_name;
2111
2112
2113 WF_ENGINE.SetItemAttrText(
2114 itemtype => itemtype,
2115 itemkey => itemkey,
2116 aname => 'NTFY_LINKED_SR_CONTACT',
2117 avalue => l_notify_contact_name );
2118
2119 OPEN sel_jsp_name_csr;
2120 FETCH sel_jsp_name_csr INTO l_jsp_name;
2121 CLOSE sel_jsp_name_csr;
2122
2123 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
2124 || '?srID=' || sel_link_rec.incident_number;
2125
2126 --l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/ibuSRDetails.jsp?srID=' || sel_link_rec.incident_number;
2127 WF_ENGINE.SetItemAttrText(
2128 itemtype => itemtype,
2129 itemkey => itemkey,
2130 aname => 'NTFY_REQUEST_NUMBER_URL',
2131 avalue => l_serviceRequest_URL);
2132
2133
2134 IF (l_contact_email_list IS NULL) THEN
2135 l_contact_email_list := l_contact_email ;
2136 ELSE
2137 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
2138 END IF;
2139
2140 IF (l_html_contact_email_list IS NULL) THEN
2141 l_html_contact_email_list := l_contact_email ;
2142 ELSE
2143 l_html_contact_email_list := l_html_contact_email_list ||' '||l_contact_email;
2144 END IF;
2145
2146 -- This section gets the workflow user of the contact, if none exist create an adhoc.
2147 -- If contact does not have workflow user, create an adhoc user.
2148 -- Adhoc user name is re-used for performance.
2149 -- The same party_id could have different contact info, but workflow schema
2150 -- only has one user/role which is the party in hz_party.
2151
2152 IF (l_user IS NULL OR
2153 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
2154 (l_user is not null and l_email_address <> l_contact_email) ) THEN
2155
2156 adhoc_count := adhoc_count + 1;
2157
2158 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
2159
2160 -- need to pass display name also, otherwise the 'To' field in mail and ntfxn
2161 -- will show the adhoc name.
2162
2163 l_user_display_name := l_contact_first_name || ', ' || l_contact_last_name;
2164
2165 SetWorkflowAdhocUser(p_wf_username => l_user,
2166 p_email_address => l_contact_email,
2167 p_display_name => l_user_display_name);
2168
2169 END IF;
2170
2171 IF (l_adhoc_user_list IS NULL) THEN
2172 l_adhoc_user_list := l_user ;
2173 ELSE
2174 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
2175 END IF;
2176
2177 -- Added code for HTML Notification (01/30/2006) release 12.0
2178
2179 IF l_html_notification_flag = 'Y' THEN
2180
2181 IF l_html_adhoc_user_list IS NULL THEN
2182 l_html_adhoc_user_list := l_user;
2183 ELSE
2184 l_html_adhoc_user_list := l_html_adhoc_user_list ||' ' ||l_user;
2185 END IF ;
2186
2187 IF l_contact_type_list IS NULL THEN
2188 IF l_contact_type = 'EMPLOYEE' THEN
2189 l_contact_type_list := 'EMP';
2190 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2191 l_contact_type_list := 'PARTY';
2192 END IF;
2193 ELSE
2194 IF l_contact_type = 'EMPLOYEE' THEN
2195 l_contact_type_list := l_contact_type_list||' '||'EMP';
2196 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2197 l_contact_type_list := l_contact_type_list||' '||'PARTY';
2198 END IF;
2199 END IF ;
2200
2201 IF l_contact_id_list IS NULL THEN
2202 IF l_contact_type = 'EMPLOYEE' THEN
2203 l_contact_id_list := NVL(l_person_id,l_contact_party_id);
2204 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2205 l_contact_id_list := l_contact_party_id;
2206 END IF;
2207 ELSE
2208 IF l_contact_type = 'EMPLOYEE' THEN
2209 l_contact_id_list := l_contact_id_list||' '||NVL(l_person_id,l_contact_party_id);
2210 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2211 l_contact_id_list := l_contact_id_list||' '||l_contact_party_id;
2212 END IF;
2213 END IF ;
2214
2215 IF l_notification_pref_list IS NULL THEN
2216 l_notification_pref_list := NVL(l_notification_preference,'MAILTEXT');
2217 ELSE
2218 l_notification_pref_list := l_notification_pref_list||' '||NVL(l_notification_preference,'MAILTEXT');
2219 END IF ;
2220
2221 IF l_language_list IS NULL THEN
2222 l_language_list := NVL(l_language,'AMERICAN');
2223 ELSE
2224 l_language_list := l_language_list||' '||NVL(l_language,'AMERICAN');
2225 END IF ;
2226 END IF ; -- end if for l_html_notification_flag
2227
2228 -- 11.5.10 enhancement for create interaction when email to contact sent.
2229
2230 IF l_contact_type <> 'EMPLOYEE' THEN
2231
2232 IF (l_contact_party_id_list IS NULL) THEN
2233 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
2234 ELSE
2235 l_contact_party_id_list := l_contact_party_id_list || ' '
2236 || TO_CHAR(l_contact_party_id);
2237 END IF;
2238 END IF;
2239
2240 -- end 11.5.10 enhancement.
2241 END IF;
2242
2243 ELSE
2244 EXIT;
2245 END IF;
2246
2247 END LOOP;
2248 CLOSE get_primary_contact_info;
2249
2250 l_request_id := WF_ENGINE.GetItemAttrNumber(
2251 itemtype => itemtype,
2252 itemkey => itemkey,
2253 aname => 'REQUEST_ID' );
2254
2255 -- Fix for bug 3392429. Only create ADHOC role and notification if there
2256 -- is/are email addresses, since we send notifications for contacts via
2257 -- email only. rmanabat 02/12/04 .
2258 IF (l_contact_email_list IS NOT NULL) THEN
2259
2260 -- If there's just one user in the list, then make the recipient that user.
2261 IF (instr(l_adhoc_user_list, ',') = 0) THEN
2262 l_notify_recipient := l_adhoc_user_list;
2263 ELSE
2264 -- We send mass notifications to one ADHOC role which has the list of
2265 -- contact's workflow users.
2266 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
2267 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
2268 p_user_list => l_adhoc_user_list);
2269 l_notify_recipient := l_adhoc_role;
2270 END IF;
2271
2272 ELSE
2273 l_notify_recipient := NULL;
2274 END IF;
2275
2276
2277 -- 11.5.10 enhancement to Create Interaction when email to contact sent.
2278 /* Roopa - begin bug 3360069 */
2279 /* Replacing the AddItemAttr() call with WF_Engine add, get and set calls
2280 to factor in the scenario where this attr already exists */
2281
2282 IF (l_contact_party_id_list IS NOT NULL) THEN
2283
2284 OPEN check_if_item_attr_exists_csr;
2285 FETCH check_if_item_attr_exists_csr into l_temp_contact_id_list;
2286
2287
2288 /****
2289 l_temp_contact_id_list := null;
2290 l_temp_contact_id_list := WF_ENGINE.GetItemAttrText( itemtype,
2291 itemkey,
2292 'CONTACT_PARTY_ID_LIST',
2293 TRUE);
2294
2295
2296 IF(l_temp_contact_id_list is NULL) THEN
2297 *****/
2298
2299 IF(check_if_item_attr_exists_csr%NOTFOUND) THEN
2300 WF_ENGINE.AddItemAttr( itemtype,
2301 itemkey,
2302 'CONTACT_PARTY_ID_LIST',
2303 l_contact_party_id_list);
2304 ELSE
2305
2306 WF_ENGINE.SetItemAttrText(
2307 itemtype => itemtype,
2308 itemkey => itemkey,
2309 aname => 'CONTACT_PARTY_ID_LIST',
2310 avalue => l_contact_party_id_list);
2311
2312
2313 END IF;
2314
2315 CLOSE check_if_item_attr_exists_csr;
2316
2317 END IF;
2318 /* Roopa - End bug 3360069 */
2319
2320 ELSE
2321 null;
2322 END IF; /*** IF (l_linked_subject_list IS NOT NULL) ***/
2323
2324 -- END LOOP;
2325
2326 -- set the item attributes for html notification
2327
2328 IF l_html_notification_flag = 'Y' THEN
2329 WF_ENGINE.SetItemAttrText(
2330 itemtype => itemtype,
2331 itemkey => itemkey,
2332 AName => 'ADHOC_USER_LIST',
2333 AValue => l_html_adhoc_user_list);
2334
2335 WF_ENGINE.SetItemAttrText(
2336 itemtype => itemtype,
2337 itemkey => itemkey,
2338 AName => 'CONTACT_ID_LIST',
2339 AValue => l_contact_id_list);
2340
2341 WF_ENGINE.SetItemAttrText(
2342 itemtype => itemtype,
2343 itemkey => itemkey,
2344 AName => 'CONTACT_EMAIL_LIST',
2345 AValue => l_html_contact_email_list);
2346
2347 WF_ENGINE.SetItemAttrText(
2348 itemtype => itemtype,
2349 itemkey => itemkey,
2350 AName => 'CONTACT_TYPE_LIST',
2351 AValue => l_contact_type_list);
2352
2353 WF_ENGINE.SetItemAttrText(
2354 itemtype => itemtype,
2355 itemkey => itemkey,
2356 AName => 'NOTIFICATION_PREFERENCE_LIST',
2357 AValue => l_notification_pref_list);
2358
2359 WF_ENGINE.SetItemAttrText(
2360 itemtype => itemtype,
2361 itemkey => itemkey,
2362 AName => 'LANGUAGE_LIST',
2363 AValue => l_language_list);
2364 END IF;
2365
2366 ELSIF (l_action_code = 'NOTIFY_ALL_CONTACTS_OF_REL_SR') THEN
2367
2368 OPEN c_check_html_notification;
2369 FETCH c_check_html_notification INTO l_html_notification_flag ;
2370 CLOSE c_check_html_notification;
2371
2372 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
2373 itemtype => itemtype,
2374 itemkey => itemkey,
2375 aname => 'NTFY_LINKED_SUBJECT_LIST');
2376
2377
2378 -- LOOP
2379 IF (l_linked_subject_list IS NOT NULL) THEN
2380 pull_from_list(itemlist => l_linked_subject_list,
2381 element => l_element);
2382
2383 l_notify_subject_id := TO_NUMBER(l_element);
2384
2385 WF_ENGINE.SetItemAttrText(
2386 itemtype => itemtype,
2387 itemkey => itemkey,
2388 aname => 'NTFY_LINKED_SUBJECT_LIST',
2389 avalue => l_linked_subject_list );
2390
2391 WF_ENGINE.SetItemAttrNumber(
2392 itemtype => itemtype,
2393 itemkey => itemkey,
2394 aname => 'NTFY_SUBJECT_ID',
2395 avalue => l_notify_subject_id );
2396
2397 OPEN sel_link_csr;
2398 FETCH sel_link_csr INTO sel_link_rec;
2399 CLOSE sel_link_csr;
2400
2401 OPEN sel_linked_sr_type_csr;
2402 FETCH sel_linked_sr_type_csr INTO sel_linked_sr_type_rec;
2403 CLOSE sel_linked_sr_type_csr;
2404
2405 l_user_id := WF_ENGINE.GetItemAttrNumber(
2406 itemtype => itemtype,
2407 itemkey => itemkey,
2408 aname => 'USER_ID' );
2409
2410 WF_ENGINE.SetItemAttrText(
2411 itemtype => itemtype,
2412 itemkey => itemkey,
2413 aname => 'NTFY_LINKED_INCIDENT_NUMBER',
2414 avalue => sel_link_rec.incident_number );
2415
2416 -- Get link Type name from link_type_id
2417
2418 WF_ENGINE.SetItemAttrText(
2419 itemtype => itemtype,
2420 itemkey => itemkey,
2421 aname => 'NTFY_LINK_TYPE',
2422 avalue => sel_linked_sr_type_rec.link_type_name );
2423
2424
2425 l_request_id := l_notify_subject_id;
2426 OPEN sel_all_contacts_csr;
2427 LOOP
2428
2429 FETCH sel_all_contacts_csr
2430 INTO l_contact_email, l_contact_party_id, l_person_id, l_contact_type, l_tmp_contact_point_id;
2431 EXIT WHEN sel_all_contacts_csr%NOTFOUND;
2432
2433 -- Check for WF email list length not to exceed 2000
2434 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
2435
2436
2437 IF (l_contact_email IS NOT NULL)THEN
2438 OPEN sel_contact_name_csr;
2439 FETCH sel_contact_name_csr INTO sel_contact_name_rec;
2440 CLOSE sel_contact_name_csr;
2441
2442 l_notify_contact_name := sel_contact_name_rec.first_name || ' ' || sel_contact_name_rec.last_name;
2443 WF_ENGINE.SetItemAttrText(
2444 itemtype => itemtype,
2445 itemkey => itemkey,
2446 aname => 'NTFY_LINKED_SR_CONTACT',
2447 avalue => l_notify_contact_name );
2448
2449 OPEN sel_jsp_name_csr;
2450 FETCH sel_jsp_name_csr INTO l_jsp_name;
2451 CLOSE sel_jsp_name_csr;
2452
2453 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
2454 || '?srID=' || l_request_number;
2455
2456 --l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/ibuSRDetails.jsp?srID=' || l_request_number;
2457 WF_ENGINE.SetItemAttrText(
2458 itemtype => itemtype,
2459 itemkey => itemkey,
2460 aname => 'NTFY_REQUEST_NUMBER_URL',
2461 avalue => l_serviceRequest_URL);
2462
2463 IF (l_contact_email_list IS NULL) THEN
2464 l_contact_email_list := l_contact_email ;
2465 ELSE
2466 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
2467 END IF;
2468
2469
2470 IF (l_html_contact_email_list IS NULL) THEN
2471 l_html_contact_email_list := l_contact_email ;
2472 ELSE
2473 l_html_contact_email_list := l_html_contact_email_list ||' '||l_contact_email;
2474 END IF;
2475
2476 -- This section gets the workflow user of the contact, if none exist create an adhoc.
2477 IF (l_contact_type = 'EMPLOYEE') THEN
2478 l_orig_system := 'PER';
2479 l_orig_system_id := l_person_id;
2480 ELSE
2481 l_orig_system := 'HZ_PARTY';
2482 l_orig_system_id := l_contact_party_id;
2483 END IF;
2484
2485 /****
2486 WF_DIRECTORY.GetUserName( p_orig_system => l_orig_system,
2487 p_orig_system_id => l_orig_system_id,
2488 p_name => l_user,
2489 p_display_name => l_user_display_name);
2490 ***/
2491
2492 OPEN c_user(l_orig_system,l_orig_system_id);
2493 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
2494 CLOSE c_user;
2495
2496 -- If contact does not have workflow user, create an adhoc user.
2497 -- Adhoc user name is re-used for performance.
2498 -- The same party_id could have different contact info, but workflow schema
2499 -- only has one user/role which is the party in hz_party.
2500
2501 IF (l_user IS NULL OR
2502 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
2503 (l_user is not null and l_email_address <> l_contact_email) ) THEN
2504
2505 adhoc_count := adhoc_count + 1;
2506
2507 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
2508
2509 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
2510 -- will show the adhoc name.
2511 l_user_display_name := sel_contact_name_rec.last_name || ', ' || sel_contact_name_rec.first_name;
2512
2513 SetWorkflowAdhocUser(p_wf_username => l_user,
2514 p_email_address => l_contact_email,
2515 p_display_name => l_user_display_name);
2516
2517 END IF;
2518
2519
2520 IF (l_adhoc_user_list IS NULL) THEN
2521 l_adhoc_user_list := l_user ;
2522 ELSE
2523 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
2524 END IF;
2525
2526
2527 -- Added code for HTML Notification (01/30/2006) release 12.0
2528
2529 IF l_html_notification_flag = 'Y' THEN
2530
2531 IF l_html_adhoc_user_list IS NULL THEN
2532 l_html_adhoc_user_list := l_user;
2533 ELSE
2534 l_html_adhoc_user_list := l_html_adhoc_user_list ||' ' ||l_user;
2535 END IF ;
2536
2537 IF l_contact_type_list IS NULL THEN
2538 IF l_contact_type = 'EMPLOYEE' THEN
2539 l_contact_type_list := 'EMP';
2540 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2541 l_contact_type_list := 'PARTY';
2542 END IF;
2543 ELSE
2544 IF l_contact_type = 'EMPLOYEE' THEN
2545 l_contact_type_list := l_contact_type_list||' '||'EMP';
2546 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2547 l_contact_type_list := l_contact_type_list||' '||'PARTY';
2548 END IF;
2549 END IF ;
2550
2551 IF l_contact_id_list IS NULL THEN
2552 IF l_contact_type = 'EMPLOYEE' THEN
2553 l_contact_id_list := l_person_id;
2554 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2555 l_contact_id_list := l_contact_party_id;
2556 END IF;
2557 ELSE
2558 IF l_contact_type = 'EMPLOYEE' THEN
2559 l_contact_id_list := l_contact_id_list||' '||l_person_id;
2560 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
2561 l_contact_id_list := l_contact_id_list||' '||l_contact_party_id;
2562 END IF;
2563 END IF ;
2564
2565 IF l_notification_pref_list IS NULL THEN
2566 l_notification_pref_list := NVL(l_notification_preference,'MAILTEXT');
2567 ELSE
2568 l_notification_pref_list := l_notification_pref_list||' '||NVL(l_notification_preference,'MAILTEXT');
2569 END IF ;
2570
2571 IF l_language_list IS NULL THEN
2572 l_language_list := NVL(l_language,'AMERICAN');
2573 ELSE
2574 l_language_list := l_language_list||' '||NVL(l_language,'AMERICAN');
2575 END IF ;
2576
2577 END IF ; -- end if for l_html_notification_flag
2578
2579 -- 11.5.10 enhancement for create interaction when email to contact sent.
2580
2581 IF (l_contact_party_id_list IS NULL) THEN
2582 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
2583 ELSE
2584 l_contact_party_id_list := l_contact_party_id_list || ' '
2585 || TO_CHAR(l_contact_party_id);
2586 END IF;
2587 -- end 11.5.10 enhancement.
2588 END IF;
2589
2590 ELSE
2591 exit;
2592 END IF;
2593 END LOOP;
2594 CLOSE sel_all_contacts_csr;
2595
2596 l_request_id := WF_ENGINE.GetItemAttrNumber(
2597 itemtype => itemtype,
2598 itemkey => itemkey,
2599 aname => 'REQUEST_ID' );
2600
2601 -- Fix for bug 3392429. Only create ADHOC role and notification if there
2602 -- is/are email addresses, since we send notifications for contacts via
2603 -- email only. rmanabat 02/12/04 .
2604
2605 IF (l_contact_email_list IS NOT NULL) THEN
2606
2607 -- If there's just one user in the list, then make the recipient that user.
2608
2609 IF (instr(l_adhoc_user_list, ',') = 0) THEN
2610 l_notify_recipient := l_adhoc_user_list;
2611 ELSE
2612 -- We send mass notifications to one ADHOC role which has the list of
2613 -- contact's workflow users.
2614 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
2615 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
2616 p_user_list => l_adhoc_user_list);
2617 l_notify_recipient := l_adhoc_role;
2618 END IF;
2619
2620 ELSE
2621 l_notify_recipient := NULL;
2622 END IF;
2623
2624 -- 11.5.10 enhancement to Create Interaction when email to contact sent.
2625 /* Roopa - begin bug 3360069 */
2626 /* Replacing the AddItemAttr() call with WF_Engine add, get and set calls
2627 to factor in the scenario where this attr already exists */
2628
2629 IF (l_contact_party_id_list IS NOT NULL) THEN
2630
2631 OPEN check_if_item_attr_exists_csr;
2632 FETCH check_if_item_attr_exists_csr into l_temp_contact_id_list;
2633
2634 /****
2635 l_temp_contact_id_list := null;
2636 l_temp_contact_id_list := WF_ENGINE.GetItemAttrText( itemtype,
2637 itemkey,
2638 'CONTACT_PARTY_ID_LIST',
2639 TRUE);
2640
2641 IF(l_temp_contact_id_list is NULL) THEN
2642 *****/
2643
2644 IF(check_if_item_attr_exists_csr%NOTFOUND) THEN
2645 WF_ENGINE.AddItemAttr( itemtype,
2646 itemkey,
2647 'CONTACT_PARTY_ID_LIST',
2648 l_contact_party_id_list);
2649 ELSE
2650 WF_ENGINE.SetItemAttrText(
2651 itemtype => itemtype,
2652 itemkey => itemkey,
2653 aname => 'CONTACT_PARTY_ID_LIST',
2654 avalue => l_contact_party_id_list);
2655 END IF;
2656 CLOSE check_if_item_attr_exists_csr;
2657
2658 END IF;
2659
2660 /* Roopa - End bug 3360069 */
2661
2662 ELSE
2663 null;
2664 END IF; /*** IF (l_linked_subject_list IS NOT NULL) ***/
2665
2666 -- END LOOP;
2667
2668 -- set the item attributes for html notification
2669
2670 IF l_html_notification_flag = 'Y' THEN
2671
2672 WF_ENGINE.SetItemAttrText(
2673 itemtype => itemtype,
2674 itemkey => itemkey,
2675 AName => 'ADHOC_USER_LIST',
2676 AValue => l_html_adhoc_user_list);
2677
2678 WF_ENGINE.SetItemAttrText(
2679 itemtype => itemtype,
2680 itemkey => itemkey,
2681 AName => 'CONTACT_ID_LIST',
2682 AValue => l_contact_id_list);
2683
2684 WF_ENGINE.SetItemAttrText(
2685 itemtype => itemtype,
2686 itemkey => itemkey,
2687 AName => 'CONTACT_EMAIL_LIST',
2688 AValue => l_html_contact_email_list);
2689
2690 WF_ENGINE.SetItemAttrText(
2691 itemtype => itemtype,
2692 itemkey => itemkey,
2693 AName => 'CONTACT_TYPE_LIST',
2694 AValue => l_contact_type_list);
2695
2696 WF_ENGINE.SetItemAttrText(
2697 itemtype => itemtype,
2698 itemkey => itemkey,
2699 AName => 'NOTIFICATION_PREFERENCE_LIST',
2700 AValue => l_notification_pref_list);
2701
2702 WF_ENGINE.SetItemAttrText(
2703 itemtype => itemtype,
2704 itemkey => itemkey,
2705 AName => 'LANGUAGE_LIST',
2706 AValue => l_language_list);
2707
2708 END IF;
2709
2710 /* END ROOPA - 11/12/03 */
2711
2712 /*----- Start of Associated Party changes for Related SR -------*/
2713
2714 ELSIF (l_action_code = 'NOTIFY_ALL_ASSOCIATED_PARTIES') THEN
2715
2716
2717 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
2718 itemtype => itemtype,
2719 itemkey => itemkey,
2720 aname => 'NTFY_LINKED_SUBJECT_LIST');
2721
2722 l_notify_relsr_party_role_list := WF_ENGINE.GetItemAttrText(
2723 itemtype => itemtype,
2724 itemkey => itemkey,
2725 aname => 'NOTIFY_RELSR_PARTY_ROLE_LIST');
2726
2727 pull_from_list(itemlist => l_notify_relsr_party_role_list,
2728 element => l_element);
2729
2730 l_party_role_code := l_element;
2731
2732 IF (l_party_role_code IS NOT NULL) THEN
2733 OPEN c_party_role_csr (l_party_role_code);
2734 FETCH c_party_role_csr INTO l_party_role_name;
2735
2736 IF c_party_role_csr%NOTFOUND THEN
2737 return;
2738 END IF;
2739 CLOSE c_party_role_csr;
2740 ELSE
2741 RETURN;
2742 END IF;
2743
2744 WF_ENGINE.SetItemAttrText(
2745 itemtype => itemtype,
2746 itemkey => itemkey,
2747 aname => 'PARTY_ROLE_NAME',
2748 avalue => l_party_role_name );
2749
2750 WF_ENGINE.SetItemAttrText(
2751 itemtype => itemtype,
2752 itemkey => itemkey,
2753 aname => 'NOTIFY_RELSR_PARTY_ROLE_LIST',
2754 avalue => l_notify_relsr_party_role_list);
2755
2756 -- LOOP
2757 IF (l_linked_subject_list IS NOT NULL) THEN
2758 pull_from_list(itemlist => l_linked_subject_list,
2759 element => l_element);
2760
2761 l_notify_subject_id := TO_NUMBER(l_element);
2762
2763 WF_ENGINE.SetItemAttrText(
2764 itemtype => itemtype,
2765 itemkey => itemkey,
2766 aname => 'NTFY_LINKED_SUBJECT_LIST',
2767 avalue => l_linked_subject_list );
2768
2769 WF_ENGINE.SetItemAttrNumber(
2770 itemtype => itemtype,
2771 itemkey => itemkey,
2772 aname => 'NTFY_SUBJECT_ID',
2773 avalue => l_notify_subject_id );
2774
2775 OPEN sel_link_csr;
2776 FETCH sel_link_csr INTO sel_link_rec;
2777 CLOSE sel_link_csr;
2778
2779 OPEN sel_linked_sr_type_csr;
2780 FETCH sel_linked_sr_type_csr INTO sel_linked_sr_type_rec;
2781 CLOSE sel_linked_sr_type_csr;
2782
2783 l_user_id := WF_ENGINE.GetItemAttrNumber(
2784 itemtype => itemtype,
2785 itemkey => itemkey,
2786 aname => 'USER_ID' );
2787
2788 WF_ENGINE.SetItemAttrText(
2789 itemtype => itemtype,
2790 itemkey => itemkey,
2791 aname => 'NTFY_LINKED_INCIDENT_NUMBER',
2792 avalue => sel_link_rec.incident_number );
2793
2794 -- Get link Type name from link_type_id
2795
2796 WF_ENGINE.SetItemAttrText(
2797 itemtype => itemtype,
2798 itemkey => itemkey,
2799 aname => 'NTFY_LINK_TYPE',
2800 avalue => sel_linked_sr_type_rec.link_type_name );
2801
2802 l_request_id := l_notify_subject_id;
2803
2804 OPEN sel_linked_sr_details_csr;
2805 FETCH sel_linked_sr_details_csr into sel_linked_sr_details_rec;
2806 CLOSE sel_linked_sr_details_csr;
2807
2808 WF_ENGINE.SetItemAttrText(
2809 itemtype => itemtype,
2810 itemkey => itemkey,
2811 aname => 'NTFY_LINKED_SR_STATUS',
2812 avalue => sel_linked_sr_details_rec.name );
2813
2814
2815
2816 WF_ENGINE.SetItemAttrText(
2817 itemtype => itemtype,
2818 itemkey => itemkey,
2819 aname => 'NTFY_LINKED_SR_SUMMARY',
2820 avalue => sel_linked_sr_details_rec.summary );
2821
2822 OPEN sel_party_role_contacts_csr;
2823 LOOP
2824
2825 FETCH sel_party_role_contacts_csr
2826 INTO l_contact_email, l_contact_party_id, l_person_id, l_contact_type, l_tmp_contact_point_id;
2827 EXIT WHEN sel_party_role_contacts_csr%NOTFOUND;
2828
2829 -- Check for WF email list length not to exceed 2000
2830 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
2831
2832 IF (l_contact_email IS NOT NULL)THEN
2833 OPEN sel_contact_name_csr;
2834 FETCH sel_contact_name_csr INTO sel_contact_name_rec;
2835 CLOSE sel_contact_name_csr;
2836
2837 l_notify_contact_name := sel_contact_name_rec.first_name || ' ' || sel_contact_name_rec.last_name;
2838 WF_ENGINE.SetItemAttrText(
2839 itemtype => itemtype,
2840 itemkey => itemkey,
2841 aname => 'NTFY_LINKED_SR_CONTACT',
2842 avalue => l_notify_contact_name );
2843
2844 OPEN sel_jsp_name_csr;
2845 FETCH sel_jsp_name_csr INTO l_jsp_name;
2846 CLOSE sel_jsp_name_csr;
2847
2848 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
2849 || '?srID=' || l_request_number;
2850
2851 WF_ENGINE.SetItemAttrText(
2852 itemtype => itemtype,
2853 itemkey => itemkey,
2854 aname => 'NTFY_REQUEST_NUMBER_URL',
2855 avalue => l_serviceRequest_URL);
2856
2857 IF (l_contact_email_list IS NULL) THEN
2858 l_contact_email_list := l_contact_email ;
2859 ELSE
2860 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
2861 END IF;
2862
2863 IF (l_contact_type = 'EMPLOYEE') THEN
2864 l_orig_system := 'PER';
2865 l_orig_system_id := l_person_id;
2866 ELSE
2867 l_orig_system := 'HZ_PARTY';
2868 l_orig_system_id := l_contact_party_id;
2869 END IF;
2870
2871 OPEN c_user(l_orig_system,l_orig_system_id);
2872 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
2873 CLOSE c_user;
2874
2875 -- If contact does not have workflow user, create an adhoc user.
2876 -- Adhoc user name is re-used for performance.
2877 -- The same party_id could have different contact info, but workflow schema
2878 -- only has one user/role which is the party in hz_party.
2879
2880 IF (l_user IS NULL OR
2881 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
2882 (l_user is not null and l_email_address <> l_contact_email) ) THEN
2883
2884 adhoc_count := adhoc_count + 1;
2885
2886 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
2887
2888 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
2889 -- will show the adhoc name.
2890 l_user_display_name := sel_contact_name_rec.last_name || ', ' || sel_contact_name_rec.first_name;
2891
2892 SetWorkflowAdhocUser(p_wf_username => l_user,
2893 p_email_address => l_contact_email,
2894 p_display_name => l_user_display_name);
2895
2896 END IF;
2897
2898 IF (l_adhoc_user_list IS NULL) THEN
2899 l_adhoc_user_list := l_user ;
2900 ELSE
2901 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
2902 END IF;
2903
2904 -- 11.5.10 enhancement for create interaction when email to contact sent.
2905 IF (l_contact_party_id_list IS NULL) THEN
2906 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
2907 ELSE
2908 l_contact_party_id_list := l_contact_party_id_list || ' '
2909 || TO_CHAR(l_contact_party_id);
2910 END IF;
2911 -- end 11.5.10 enhancement.
2912 END IF;
2913 ELSE
2914 exit;
2915 END IF;
2916 END LOOP;
2917 CLOSE sel_party_role_contacts_csr;
2918
2919 l_request_id := WF_ENGINE.GetItemAttrNumber(
2920 itemtype => itemtype,
2921 itemkey => itemkey,
2922 aname => 'REQUEST_ID' );
2923
2924 -- Fix for bug 3392429. Only create ADHOC role and notification if there
2925 -- is/are email addresses, since we send notifications for contacts via
2926 -- email only. rmanabat 02/12/04 .
2927 IF (l_contact_email_list IS NOT NULL) THEN
2928
2929 -- If there's just one user in the list, then make the recipient that user.
2930 IF (instr(l_adhoc_user_list, ',') = 0) THEN
2931 l_notify_recipient := l_adhoc_user_list;
2932 ELSE
2933 -- We send mass notifications to one ADHOC role which has the list of
2934 -- contact's workflow users.
2935 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
2936 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
2937 p_user_list => l_adhoc_user_list);
2938 l_notify_recipient := l_adhoc_role;
2939 END IF;
2940
2941 ELSE
2942 l_notify_recipient := NULL;
2943 END IF;
2944
2945 ELSE
2946 null;
2947 END IF; /*** IF (l_linked_subject_list IS NOT NULL) ***/
2948 /* END ROOPA - 11/12/03 */
2949
2950
2951 /*------------- End of Associated Party Related SR changes ----------------*/
2952
2953 ELSIF (l_action_code = 'NOTIFY_ALL_CONTACTS') THEN
2954
2955 /****************************************
2956 For contacts, we shall be creating a workflow Adhoc role
2957 when nececessary since not all contacts are employees or
2958 have workflow roles, e.g., customer contact.
2959 We will be sending just one notification message for all the contacts
2960 who has e-mail addresses. The recipient role would include the list of
2961 the contact's workflow user names. This is less expensive than
2962 sending one e-mail for each contact.
2963 *****************************************/
2964
2965 -- Check if the html_notification flag is set
2966
2967 OPEN c_check_html_notification;
2968 FETCH c_check_html_notification INTO l_html_notification_flag ;
2969 CLOSE c_check_html_notification;
2970
2971 OPEN sel_all_contacts_csr;
2972
2973 LOOP
2974
2975 FETCH sel_all_contacts_csr
2976 INTO l_contact_email, l_contact_party_id, l_person_id, l_contact_type, l_tmp_contact_point_id;
2977 EXIT WHEN sel_all_contacts_csr%NOTFOUND;
2978
2979 -- Check for WF email list length not to exceed 2000
2980 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
2981
2982 IF (l_contact_email_list IS NULL) THEN
2983 l_contact_email_list := l_contact_email ;
2984 ELSE
2985 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
2986 END IF;
2987
2988 IF (l_html_contact_email_list IS NULL) THEN
2989 l_html_contact_email_list := l_contact_email ;
2990 ELSE
2991 l_html_contact_email_list := l_html_contact_email_list ||' '||l_contact_email;
2992 END IF;
2993
2994 -- This section gets the workflow user of the contact, if none exist create an adhoc.
2995
2996 IF (l_contact_type = 'EMPLOYEE') THEN
2997 l_orig_system := 'PER';
2998 l_orig_system_id := l_person_id;
2999 ELSE
3000 l_orig_system := 'HZ_PARTY';
3001 l_orig_system_id := l_contact_party_id;
3002 END IF;
3003
3004 /****
3005 WF_DIRECTORY.GetUserName( p_orig_system => l_orig_system,
3006 p_orig_system_id => l_orig_system_id,
3007 p_name => l_user,
3008 p_display_name => l_user_display_name);
3009 ***/
3010
3011 OPEN c_user(l_orig_system,l_orig_system_id);
3012 FETCH c_user
3013 INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
3014 CLOSE c_user;
3015
3016 -- If contact does not have workflow user, create an adhoc user.
3017 -- Adhoc user name is re-used for performance.
3018 -- The same party_id could have different contact info, but workflow schema
3019 -- only has one user/role which is the party in hz_party.
3020
3021 IF (l_user IS NULL OR
3022 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
3023 (l_user is not null and l_email_address <> l_contact_email) ) THEN
3024
3025 adhoc_count := adhoc_count + 1;
3026
3027 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
3028
3029 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
3030 -- will show the adhoc name.
3031
3032 OPEN sel_contact_name_csr;
3033 FETCH sel_contact_name_csr INTO sel_contact_name_rec;
3034 l_user_display_name := sel_contact_name_rec.last_name || ', ' || sel_contact_name_rec.first_name;
3035 CLOSE sel_contact_name_csr;
3036
3037 SetWorkflowAdhocUser(p_wf_username => l_user,
3038 p_email_address => l_contact_email,
3039 p_display_name => l_user_display_name);
3040
3041 END IF;
3042
3043 IF (l_adhoc_user_list IS NULL) THEN
3044 l_adhoc_user_list := l_user ;
3045 ELSE
3046 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
3047 END IF;
3048
3049 -- Added code for HTML Notification (01/30/2006) release 12.0
3050
3051 IF l_html_notification_flag = 'Y' THEN
3052
3053 IF l_html_adhoc_user_list IS NULL THEN
3054 l_html_adhoc_user_list := l_user;
3055 ELSE
3056 l_html_adhoc_user_list := l_html_adhoc_user_list ||' ' ||l_user;
3057 END IF ;
3058
3059 IF l_contact_type_list IS NULL THEN
3060 IF l_contact_type = 'EMPLOYEE' THEN
3061 l_contact_type_list := 'EMP';
3062 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3063 l_contact_type_list := 'PARTY';
3064 END IF;
3065 ELSE
3066 IF l_contact_type = 'EMPLOYEE' THEN
3067 l_contact_type_list := l_contact_type_list||' '||'EMP';
3068 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3069 l_contact_type_list := l_contact_type_list||' '||'PARTY';
3070 END IF;
3071 END IF ;
3072
3073 IF l_contact_id_list IS NULL THEN
3074 IF l_contact_type = 'EMPLOYEE' THEN
3075 l_contact_id_list := l_person_id;
3076 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3077 l_contact_id_list := l_contact_party_id;
3078 END IF;
3079 ELSE
3080 IF l_contact_type = 'EMPLOYEE' THEN
3081 l_contact_id_list := l_contact_id_list||' '||l_person_id;
3082 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3083 l_contact_id_list := l_contact_id_list||' '||l_contact_party_id;
3084 END IF;
3085 END IF ;
3086
3087 IF l_notification_pref_list IS NULL THEN
3088 l_notification_pref_list := NVL(l_notification_preference,'MAILTEXT');
3089 ELSE
3090 l_notification_pref_list := l_notification_pref_list||' '||NVL(l_notification_preference,'MAILTEXT');
3091 END IF ;
3092
3093 IF l_language_list IS NULL THEN
3094 l_language_list := NVL(l_language,'AMERICAN');
3095 ELSE
3096 l_language_list := l_language_list||' '||NVL(l_language,'AMERICAN');
3097 END IF ;
3098
3099 END IF ; -- end if for l_html_notification_flag
3100
3101 -- 11.5.10 enhancement for create interaction when email to contact sent.
3102
3103 IF (l_contact_party_id_list IS NULL) THEN
3104 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
3105 ELSE
3106 l_contact_party_id_list := l_contact_party_id_list || ' '
3107 || TO_CHAR(l_contact_party_id);
3108 END IF;
3109 -- end 11.5.10 enhancement.
3110
3111 ELSE
3112 EXIT;
3113 END IF;
3114
3115 END LOOP;
3116 CLOSE sel_all_contacts_csr;
3117
3118 -- set the item attributes for html notification
3119
3120 IF l_html_notification_flag = 'Y' THEN
3121
3122 WF_ENGINE.SetItemAttrText
3123 ( itemtype => itemtype,
3124 itemkey => itemkey,
3125 AName => 'ADHOC_USER_LIST',
3126 AValue => l_html_adhoc_user_list);
3127
3128 WF_ENGINE.SetItemAttrText
3129 ( itemtype => itemtype,
3130 itemkey => itemkey,
3131 AName => 'CONTACT_ID_LIST',
3132 AValue => l_contact_id_list);
3133
3134 WF_ENGINE.SetItemAttrText
3135 ( itemtype => itemtype,
3136 itemkey => itemkey,
3137 AName => 'CONTACT_EMAIL_LIST',
3138 AValue => l_html_contact_email_list);
3139
3140 WF_ENGINE.SetItemAttrText
3141 ( itemtype => itemtype,
3142 itemkey => itemkey,
3143 AName => 'CONTACT_TYPE_LIST',
3144 AValue => l_contact_type_list);
3145
3146 WF_ENGINE.SetItemAttrText
3147 ( itemtype => itemtype,
3148 itemkey => itemkey,
3149 AName => 'NOTIFICATION_PREFERENCE_LIST',
3150 AValue => l_notification_pref_list);
3151
3152 WF_ENGINE.SetItemAttrText
3153 ( itemtype => itemtype,
3154 itemkey => itemkey,
3155 AName => 'LANGUAGE_LIST',
3156 AValue => l_language_list);
3157
3158 END IF;
3159
3160 OPEN sel_jsp_name_csr;
3161 FETCH sel_jsp_name_csr INTO l_jsp_name;
3162 CLOSE sel_jsp_name_csr;
3163
3164 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
3165 || '?srID=' || l_request_number;
3166 WF_ENGINE.SetItemAttrText(
3167 itemtype => itemtype,
3168 itemkey => itemkey,
3169 aname => 'NTFY_REQUEST_NUMBER_URL',
3170 avalue => l_serviceRequest_URL);
3171
3172 -- Fix for bug 3392429. Only create ADHOC role and notification if there
3173 -- is/are email addresses, since we send notifications for contacts via
3174 -- email . rmanabat 02/12/04 .
3175
3176 IF (l_contact_email_list IS NOT NULL) THEN
3177
3178 -- If there's just one user in the list, then make the recipient that user.
3179
3180 IF (instr(l_adhoc_user_list, ',') = 0) THEN
3181 l_notify_recipient := l_adhoc_user_list;
3182 ELSE
3183 -- We send mass notifications to one ADHOC role which has the list of
3184 -- contact's workflow users.
3185
3186 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
3187
3188 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
3189 p_user_list => l_adhoc_user_list);
3190
3191 l_notify_recipient := l_adhoc_role;
3192
3193 END IF;
3194
3195 ELSE
3196 l_notify_recipient := NULL;
3197 END IF;
3198
3199
3200 -- 11.5.10 enhancement to Create Interaction when email to contact sent.
3201 /* Roopa - begin bug 3360069 */
3202 /* Replacing the AddItemAttr() call with WF_Engine add, get and set calls
3203 to factor in the scenario where this attr already exists */
3204
3205 IF (l_contact_party_id_list IS NOT NULL) THEN
3206
3207 OPEN check_if_item_attr_exists_csr;
3208 FETCH check_if_item_attr_exists_csr into l_temp_contact_id_list;
3209
3210 IF(check_if_item_attr_exists_csr%NOTFOUND) THEN
3211 WF_ENGINE.AddItemAttr( itemtype,
3212 itemkey,
3213 'CONTACT_PARTY_ID_LIST',
3214 l_contact_party_id_list);
3215 ELSE
3216 WF_ENGINE.SetItemAttrText(
3217 itemtype => itemtype,
3218 itemkey => itemkey,
3219 aname => 'CONTACT_PARTY_ID_LIST',
3220 avalue => l_contact_party_id_list);
3221 END IF;
3222 CLOSE check_if_item_attr_exists_csr;
3223
3224 END IF;
3225 /* Roopa - End bug 3360069 */
3226
3227 -- Start of code for Associated Party Notification --
3228 ELSIF (l_action_code = 'NOTIFY_ASSOCIATED_PARTIES') THEN
3229
3230
3231 l_notify_party_role_list := WF_ENGINE.GetItemAttrText(
3232 itemtype => itemtype,
3233 itemkey => itemkey,
3234 aname => 'NOTIFY_PARTY_ROLE_LIST');
3235
3236 pull_from_list(itemlist => l_notify_party_role_list,
3237 element => l_element);
3238
3239 l_party_role_code := l_element;
3240
3241 IF (l_party_role_code IS NOT NULL) THEN
3242 OPEN c_party_role_csr (l_party_role_code);
3243 FETCH c_party_role_csr INTO l_party_role_name;
3244
3245 IF c_party_role_csr%NOTFOUND THEN
3246 return;
3247 END IF;
3248 CLOSE c_party_role_csr;
3249 ELSE
3250 RETURN;
3251 END IF;
3252
3253 WF_ENGINE.SetItemAttrText(
3254 itemtype => itemtype,
3255 itemkey => itemkey,
3256 aname => 'PARTY_ROLE_NAME',
3257 avalue => l_party_role_name );
3258
3259 WF_ENGINE.SetItemAttrText(
3260 itemtype => itemtype,
3261 itemkey => itemkey,
3262 aname => 'NOTIFY_PARTY_ROLE_LIST',
3263 avalue => l_notify_party_role_list);
3264
3265
3266 OPEN sel_party_role_contacts_csr;
3267 LOOP
3268
3269 FETCH sel_party_role_contacts_csr
3270 INTO l_contact_email, l_contact_party_id, l_person_id, l_contact_type, l_tmp_contact_point_id;
3271 EXIT WHEN sel_party_role_contacts_csr%NOTFOUND;
3272 -- Check for WF email list length not to exceed 2000
3273 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
3274
3275 IF (l_contact_email_list IS NULL) THEN
3276 l_contact_email_list := l_contact_email ;
3277 ELSE
3278 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
3279 END IF;
3280
3281 IF (l_contact_type = 'EMPLOYEE') THEN
3282 l_orig_system := 'PER';
3283 l_orig_system_id := l_person_id;
3284 ELSE
3285 l_orig_system := 'HZ_PARTY';
3286 l_orig_system_id := l_contact_party_id;
3287 END IF;
3288
3289 OPEN c_user(l_orig_system,l_orig_system_id);
3290 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
3291 CLOSE c_user;
3292
3293 -- If contact does not have workflow user, create an adhoc user.
3294 -- Adhoc user name is re-used for performance.
3295 -- The same party_id could have different contact info, but workflow schema
3296 -- only has one user/role which is the party in hz_party.
3297
3298 IF (l_user IS NULL OR
3299 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
3300 (l_user is not null and l_email_address <> l_contact_email) ) THEN
3301
3302 adhoc_count := adhoc_count + 1;
3303
3304 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
3305
3306 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
3307 -- will show the adhoc name.
3308 OPEN sel_contact_name_csr;
3309 FETCH sel_contact_name_csr INTO sel_contact_name_rec;
3310 l_user_display_name := sel_contact_name_rec.last_name || ', ' || sel_contact_name_rec.first_name;
3311 CLOSE sel_contact_name_csr;
3312
3313 SetWorkflowAdhocUser(p_wf_username => l_user,
3314 p_email_address => l_contact_email,
3315 p_display_name => l_user_display_name);
3316
3317 END IF;
3318
3319 IF (l_adhoc_user_list IS NULL) THEN
3320 l_adhoc_user_list := l_user ;
3321 ELSE
3322 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
3323 END IF;
3324
3325 -- 11.5.10 enhancement for create interaction when email to contact sent.
3326 IF (l_contact_party_id_list IS NULL) THEN
3327 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
3328 ELSE
3329 l_contact_party_id_list := l_contact_party_id_list || ' '
3330 || TO_CHAR(l_contact_party_id);
3331 END IF;
3332 -- end 11.5.10 enhancement.
3333
3334 ELSE
3335 EXIT;
3336
3337 END IF;
3338
3339 END LOOP;
3340 CLOSE sel_party_role_contacts_csr;
3341
3342 OPEN sel_jsp_name_csr;
3343 FETCH sel_jsp_name_csr INTO l_jsp_name;
3344 CLOSE sel_jsp_name_csr;
3345
3346 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
3347 || '?srID=' || l_request_number;
3348 WF_ENGINE.SetItemAttrText(
3349 itemtype => itemtype,
3350 itemkey => itemkey,
3351 aname => 'NTFY_REQUEST_NUMBER_URL',
3352 avalue => l_serviceRequest_URL);
3353
3354 -- Fix for bug 3392429. Only create ADHOC role and notification if there
3355 -- is/are email addresses, since we send notifications for contacts via
3356 -- email . rmanabat 02/12/04 .
3357 IF (l_contact_email_list IS NOT NULL) THEN
3358
3359 -- If there's just one user in the list, then make the recipient that user.
3360 IF (instr(l_adhoc_user_list, ',') = 0) THEN
3361 l_notify_recipient := l_adhoc_user_list;
3362 ELSE
3363 -- We send mass notifications to one ADHOC role which has the list of
3364 -- contact's workflow users.
3365 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
3366 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
3367 p_user_list => l_adhoc_user_list);
3368 l_notify_recipient := l_adhoc_role;
3369 END IF;
3370
3371 ELSE
3372 l_notify_recipient := NULL;
3373 END IF;
3374
3375 ELSIF (l_action_code = 'NOTIFY_PRIMARY_CONTACT') THEN
3376
3377 -- Get the primary contact's information
3378
3379 OPEN get_primary_contact_info;
3380 FETCH get_primary_contact_info
3381 INTO l_contact_party_id,l_contact_type,l_tmp_contact_point_id,l_sr_contact_point_type,l_sr_contact_point_id;
3382
3383 -- get the email address from the CS schema if l_contact_type is not EMAIL.
3384
3385 -- Get primary contact point ID from cs schema
3386
3387 IF l_sr_contact_point_type <> 'EMAIL' THEN
3388
3389 OPEN get_primary_email_info_CS (l_contact_party_id) ;
3390 FETCH get_primary_email_info_CS INTO l_pri_sr_contact_point_id, l_pri_email_cont_pt_id ;
3391 CLOSE get_primary_email_info_CS;
3392
3393 -- get the email address if contact point id found in CS schema.
3394
3395 IF l_pri_email_cont_pt_id IS NOT NULL THEN
3396
3397 IF (l_contact_type = 'PERSON' OR l_contact_type = 'PARTY_RELATIONSHIP') THEN
3398
3399 OPEN get_primary_email_info_HZ (l_pri_sr_contact_point_id,l_contact_party_id);
3400 FETCH get_primary_email_info_HZ INTO l_contact_email;
3401 CLOSE get_primary_email_info_HZ;
3402 ELSIF l_contact_type = 'EMPLOYEE' THEN
3403 OPEN get_primary_email_info_HR (l_contact_party_id);
3404 FETCH get_primary_email_info_HR INTO l_contact_email;
3405 CLOSE get_primary_email_info_HR;
3406 END IF;
3407 END IF;
3408
3409 END IF ;
3410
3411 -- Check if the html_notification flag is set
3412
3413 OPEN c_check_html_notification;
3414 FETCH c_check_html_notification INTO l_html_notification_flag ;
3415 CLOSE c_check_html_notification;
3416
3417 IF (get_primary_contact_info%FOUND) THEN
3418
3419 -- This section gets the workflow user of the contact, if none exist create an adhoc.
3420
3421 IF (l_contact_type = 'EMPLOYEE') THEN
3422 l_orig_system := 'PER';
3423 l_orig_system_id := l_contact_party_id; --l_person_id;
3424 ELSE
3425 l_orig_system := 'HZ_PARTY';
3426 l_orig_system_id := l_contact_party_id;
3427 END IF;
3428
3429 OPEN c_user(l_orig_system,l_orig_system_id);
3430 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
3431 CLOSE c_user;
3432
3433 -- If contact does not have workflow user, create an adhoc user.
3434 -- Adhoc user name is re-used for performance.
3435 -- The same party_id could have different contact info, but workflow schema
3436 -- only has one user/role which is the party in hz_party.
3437
3438
3439 IF (l_user IS NULL OR
3440 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
3441 (l_user is not null and l_email_address <> l_contact_email) ) THEN
3442
3443 adhoc_count := adhoc_count + 1;
3444
3445 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
3446
3447 -- Check if the email address is available.If not then get any customer email address.
3448
3449 IF ((l_email_address IS NULL) AND (l_contact_email IS NULL) AND (l_contact_type <> 'EMPLOYEE')) THEN
3450
3451 FOR get_any_cust_email_address_rec IN get_any_cust_email_address(l_contact_party_id)
3452 LOOP
3453 l_contact_email := get_any_cust_email_address_rec.email_address;
3454 EXIT WHEN get_any_cust_email_address%FOUND;
3455 END LOOP;
3456 END IF ;
3457
3458 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
3459 -- will show the adhoc name.
3460
3461 -- Get the contact name details
3462
3463 IF l_contact_type = 'PERSON' THEN
3464
3465 OPEN get_prim_cont_party_info_per(l_contact_party_id) ;
3466 FETCH get_prim_cont_party_info_per INTO l_contact_first_name , l_contact_last_name;
3467 CLOSE get_prim_cont_party_info_per;
3468
3469 ELSIF l_contact_type = 'PARTY_RELATIONSHIP' THEN
3470
3471 OPEN get_prim_cont_party_info_reln(l_contact_party_id) ;
3472 FETCH get_prim_cont_party_info_reln INTO l_contact_first_name , l_contact_last_name;
3473 CLOSE get_prim_cont_party_info_reln;
3474
3475 ELSIF l_contact_type = 'EMPLOYEE' THEN
3476
3477 OPEN get_prim_cont_party_info_empl(l_contact_party_id) ;
3478 FETCH get_prim_cont_party_info_empl INTO l_contact_first_name , l_contact_last_name;
3479 CLOSE get_prim_cont_party_info_empl;
3480
3481 END IF;
3482
3483
3484 l_user_display_name := l_contact_last_name || ', ' || l_contact_first_name;
3485
3486 SetWorkflowAdhocUser(p_wf_username => l_user,
3487 p_email_address => NVL(l_contact_email,l_email_address),
3488 p_display_name => l_user_display_name);
3489
3490 END IF;
3491
3492 -- Added code for HTML Notification (01/30/2006) release 12.0
3493
3494
3495 IF l_html_notification_flag = 'Y' THEN
3496
3497 IF (l_html_contact_email_list IS NULL) THEN
3498 l_html_contact_email_list := NVL(l_contact_email,l_email_address) ;
3499 ELSE
3500 l_html_contact_email_list := l_html_contact_email_list ||' '||NVL(l_contact_email,l_email_address);
3501 END IF;
3502
3503 IF l_html_adhoc_user_list IS NULL THEN
3504 l_html_adhoc_user_list := l_user;
3505 ELSE
3506 l_html_adhoc_user_list := l_html_adhoc_user_list||' '||l_user;
3507 END IF;
3508
3509 IF l_contact_type_list IS NULL THEN
3510 IF l_contact_type = 'EMPLOYEE' THEN
3511 l_contact_type_list := 'EMP';
3512 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3513 l_contact_type_list := 'PARTY';
3514 END IF;
3515 ELSE
3516 IF l_contact_type = 'EMPLOYEE' THEN
3517 l_contact_type_list := l_contact_type_list||' '||'EMP';
3518 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3519 l_contact_type_list := l_contact_type_list||' '||'PARTY';
3520 END IF;
3521 END IF ;
3522
3523 IF l_contact_id_list IS NULL THEN
3524 IF l_contact_type = 'EMPLOYEE' THEN
3525 l_contact_id_list := l_contact_party_id; --l_person_id;
3526 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3527 l_contact_id_list := l_contact_party_id;
3528 END IF;
3529 ELSE
3530 IF l_contact_type = 'EMPLOYEE' THEN
3531 l_contact_id_list := l_contact_id_list||' '||l_contact_party_id; --l_person_id;
3532 ELSE -- IF l_contact_type = 'HZ_PARTY' THEN
3533 l_contact_id_list := l_contact_id_list||' '||l_contact_party_id;
3534 END IF;
3535 END IF ;
3536
3537 IF l_notification_pref_list IS NULL THEN
3538 l_notification_pref_list := NVL(l_notification_preference,'MAILTEXT');
3539 ELSE
3540 l_notification_pref_list := l_notification_pref_list||' '||NVL(l_notification_preference,'MAILTEXT');
3541 END IF ;
3542
3543 IF l_language_list IS NULL THEN
3544 l_language_list := NVL(l_language,'AMERICAN');
3545 ELSE
3546 l_language_list := l_language_list||' '||NVL(l_language,'AMERICAN');
3547 END IF ;
3548
3549 END IF ; -- end if for l_html_notification_flag
3550
3551 IF l_html_notification_flag = 'Y' THEN
3552
3553 WF_ENGINE.SetItemAttrText(
3554 itemtype => itemtype,
3555 itemkey => itemkey,
3556 AName => 'ADHOC_USER_LIST',
3557 AValue => l_html_adhoc_user_list);
3558
3559 WF_ENGINE.SetItemAttrText(
3560 itemtype => itemtype,
3561 itemkey => itemkey,
3562 AName => 'CONTACT_ID_LIST',
3563 AValue => l_contact_id_list);
3564
3565 WF_ENGINE.SetItemAttrText(
3566 itemtype => itemtype,
3567 itemkey => itemkey,
3568 AName => 'CONTACT_EMAIL_LIST',
3569 AValue => l_html_contact_email_list);
3570
3571 WF_ENGINE.SetItemAttrText(
3572 itemtype => itemtype,
3573 itemkey => itemkey,
3574 AName => 'CONTACT_TYPE_LIST',
3575 AValue => l_contact_type_list);
3576
3577 WF_ENGINE.SetItemAttrText(
3578 itemtype => itemtype,
3579 itemkey => itemkey,
3580 AName => 'NOTIFICATION_PREFERENCE_LIST',
3581 AValue => l_notification_pref_list);
3582
3583 WF_ENGINE.SetItemAttrText(
3584 itemtype => itemtype,
3585 itemkey => itemkey,
3586 AName => 'LANGUAGE_LIST',
3587 AValue => l_language_list);
3588
3589 END IF;
3590
3591 --l_notify_recipient := l_adhoc_role;
3592 l_notify_recipient := l_user;
3593
3594 -- 11.5.10 enhancement to Create Interaction when email to contact sent.
3595 /* Roopa - begin bug 3360069 */
3596 /* Replacing the AddItemAttr() call with WF_Engine add, get and set calls
3597 to factor in the scenario where this attr already exists */
3598
3599 IF ((l_contact_party_id IS NOT NULL) AND (l_contact_type <> 'EMPLOYEE')) THEN
3600
3601 OPEN check_if_item_attr_exists_csr;
3602 FETCH check_if_item_attr_exists_csr into l_temp_contact_id_list;
3603
3604 IF(check_if_item_attr_exists_csr%NOTFOUND) THEN
3605 WF_ENGINE.AddItemAttr( itemtype,
3606 itemkey,
3607 'CONTACT_PARTY_ID_LIST',
3608 l_contact_party_id);
3609 ELSE
3610 WF_ENGINE.SetItemAttrText(
3611 itemtype => itemtype,
3612 itemkey => itemkey,
3613 aname => 'CONTACT_PARTY_ID_LIST',
3614 avalue => l_contact_party_id);
3615 END IF;
3616 CLOSE check_if_item_attr_exists_csr;
3617
3618 END IF;
3619
3620 OPEN sel_jsp_name_csr;
3621 FETCH sel_jsp_name_csr INTO l_jsp_name;
3622 CLOSE sel_jsp_name_csr;
3623
3624 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
3625 || '?srID=' || l_request_number;
3626 WF_ENGINE.SetItemAttrText(
3627 itemtype => itemtype,
3628 itemkey => itemkey,
3629 aname => 'NTFY_REQUEST_NUMBER_URL',
3630 avalue => l_serviceRequest_URL);
3631
3632 END IF; -- IF (get_primary_contact_info%FOUND
3633
3634 CLOSE get_primary_contact_info;
3635
3636 -- End of code for Associated Party Notification
3637
3638 ELSIF (l_action_code = 'NOTIFY_NEW_CONTACT') THEN
3639
3640 -- Check if the html_notification flag is set
3641
3642 OPEN c_check_html_notification;
3643 FETCH c_check_html_notification INTO l_html_notification_flag ;
3644 CLOSE c_check_html_notification;
3645
3646 l_contact_point_id_list := WF_ENGINE.GetItemAttrText(
3647 itemtype => itemtype,
3648 itemkey => itemkey,
3649 aname => 'NEW_CONTACT_POINT_ID_LIST' );
3650
3651 pull_from_list(itemlist => l_contact_point_id_list,
3652 element => l_element);
3653
3654 WHILE l_element IS NOT NULL LOOP
3655
3656 l_contact_point_id := TO_NUMBER(l_element);
3657
3658 OPEN sel_new_contact_csr;
3659 FETCH sel_new_contact_csr
3660 INTO l_contact_email, l_contact_party_id, l_person_id, l_contact_type, l_tmp_contact_point_id;
3661 IF (sel_new_contact_csr%FOUND OR l_contact_email IS NOT NULL)THEN
3662
3663 -- Check for WF email list length not to exceed 2000
3664 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
3665
3666 IF (l_contact_email_list IS NULL) THEN
3667 l_contact_email_list := l_contact_email ;
3668 ELSE
3669 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
3670 END IF;
3671
3672 IF (l_html_contact_email_list IS NULL) THEN
3673 l_html_contact_email_list := l_contact_email ;
3674 ELSE
3675 l_html_contact_email_list := l_html_contact_email_list ||' '||l_contact_email;
3676 END IF;
3677
3678 -- This section gets the workflow user of the contact, if none exist create an adhoc.
3679
3680 IF (l_contact_type = 'EMPLOYEE') THEN
3681 l_orig_system := 'PER';
3682 l_orig_system_id := l_person_id;
3683 ELSE
3684 l_orig_system := 'HZ_PARTY';
3685 l_orig_system_id := l_contact_party_id;
3686 END IF;
3687
3688 OPEN c_user(l_orig_system,l_orig_system_id);
3689 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
3690 CLOSE c_user;
3691
3692 -- If contact does not have workflow user, create an adhoc user.
3693 -- Adhoc user name is re-used for performance.
3694 -- The same party_id could have different contact info, but workflow schema
3695 -- only has one user/role which is the party in hz_party.
3696
3697 IF (l_user IS NULL OR
3698 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
3699 (l_user is not null and l_email_address <> l_contact_email) ) THEN
3700
3701 adhoc_count := adhoc_count + 1;
3702
3703 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
3704
3705 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
3706 -- will show the adhoc name.
3707 OPEN sel_contact_name_csr;
3708 FETCH sel_contact_name_csr INTO sel_contact_name_rec;
3709 l_user_display_name := sel_contact_name_rec.last_name || ', ' || sel_contact_name_rec.first_name;
3710 CLOSE sel_contact_name_csr;
3711
3712 SetWorkflowAdhocUser(p_wf_username => l_user,
3713 p_email_address => l_contact_email,
3714 p_display_name => l_user_display_name);
3715
3716 END IF;
3717
3718 IF (l_adhoc_user_list IS NULL) THEN
3719 l_adhoc_user_list := l_user ;
3720 ELSE
3721 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
3722 END IF;
3723
3724 IF l_html_adhoc_user_list IS NULL THEN
3725 l_html_adhoc_user_list := l_user;
3726 ELSE
3727 l_html_adhoc_user_list := l_html_adhoc_user_list ||' ' ||l_user;
3728 END IF ;
3729
3730 -- 11.5.10 enhancement for create interaction when email to contact sent.
3731 IF (l_contact_party_id_list IS NULL) THEN
3732 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
3733 ELSE
3734 l_contact_party_id_list := l_contact_party_id_list || ' '
3735 || TO_CHAR(l_contact_party_id);
3736 END IF;
3737
3738 -- end 11.5.10 enhancement.
3739
3740 ELSE
3741 EXIT;
3742
3743 END IF;
3744
3745 -- Added code for HTML Notification (01/30/2006) release 12.0
3746
3747 IF l_html_notification_flag = 'Y' THEN
3748
3749 IF l_contact_type_list IS NULL THEN
3750 IF l_contact_type = 'EMPLOYEE' THEN
3751 l_contact_type_list := 'EMP';
3752 ELSE --IF l_contact_type = 'HZ_PARTY' THEN
3753 l_contact_type_list := 'PARTY';
3754 END IF;
3755 ELSE
3756 IF l_contact_type = 'EMPLOYEE' THEN
3757 l_contact_type_list := l_contact_type_list||' '||'EMP';
3758 ELSE --IF l_contact_type = 'HZ_PARTY' THEN
3759 l_contact_type_list := l_contact_type_list||' '||'PARTY';
3760 END IF;
3761 END IF ;
3762
3763 IF l_contact_id_list IS NULL THEN
3764 IF l_contact_type = 'EMPLOYEE' THEN
3765 l_contact_id_list := l_person_id;
3766 ELSE --IF l_contact_type = 'HZ_PARTY' THEN
3767 l_contact_id_list := l_contact_party_id;
3768 END IF;
3769 ELSE
3770 IF l_contact_type = 'EMPLOYEE' THEN
3771 l_contact_id_list := l_contact_id_list||' '||l_person_id;
3772 ELSE --IF l_contact_type = 'HZ_PARTY' THEN
3773 l_contact_id_list := l_contact_id_list||' '||l_contact_party_id;
3774 END IF;
3775 END IF ;
3776
3777 IF l_notification_pref_list IS NULL THEN
3778 l_notification_pref_list := NVL(l_notification_preference,'MAILTEXT');
3779 ELSE
3780 l_notification_pref_list := l_notification_pref_list||' '||NVL(l_notification_preference,'MAILTEXT');
3781 END IF ;
3782
3783 IF l_language_list IS NULL THEN
3784 l_language_list := NVL(l_language,'AMERICAN');
3785 ELSE
3786 l_language_list := l_language_list||' '||NVL(l_language,'AMERICAN');
3787 END IF ;
3788
3789 END IF ; -- end if for l_html_notification_flag
3790
3791 IF l_html_notification_flag = 'Y' THEN
3792
3793 WF_ENGINE.SetItemAttrText(
3794 itemtype => itemtype,
3795 itemkey => itemkey,
3796 AName => 'ADHOC_USER_LIST',
3797 AValue => l_html_adhoc_user_list);
3798
3799 WF_ENGINE.SetItemAttrText(
3800 itemtype => itemtype,
3801 itemkey => itemkey,
3802 AName => 'CONTACT_ID_LIST',
3803 AValue => l_contact_id_list);
3804
3805 WF_ENGINE.SetItemAttrText(
3806 itemtype => itemtype,
3807 itemkey => itemkey,
3808 AName => 'CONTACT_EMAIL_LIST',
3809 AValue => l_html_contact_email_list);
3810
3811 WF_ENGINE.SetItemAttrText(
3812 itemtype => itemtype,
3813 itemkey => itemkey,
3814 AName => 'CONTACT_TYPE_LIST',
3815 AValue => l_contact_type_list);
3816
3817 WF_ENGINE.SetItemAttrText(
3818 itemtype => itemtype,
3819 itemkey => itemkey,
3820 AName => 'NOTIFICATION_PREFERENCE_LIST',
3821 AValue => l_notification_pref_list);
3822
3823 WF_ENGINE.SetItemAttrText(
3824 itemtype => itemtype,
3825 itemkey => itemkey,
3826 AName => 'LANGUAGE_LIST',
3827 AValue => l_language_list);
3828
3829 END IF;
3830
3831 END IF;
3832 CLOSE sel_new_contact_csr;
3833
3834 pull_from_list(itemlist => l_contact_point_id_list,
3835 element => l_element);
3836
3837 END LOOP;
3838
3839
3840 -- Fix for bug 3392429. Only create ADHOC role and notification if there
3841 -- is/are email addresses, since we send notifications for contacts via
3842 -- email . rmanabat 02/12/04 .
3843
3844 IF (l_contact_email_list IS NOT NULL) THEN
3845
3846 -- If there's just one user in the list, then make the recipient that user.
3847 IF (instr(l_adhoc_user_list, ',') = 0) THEN
3848 l_notify_recipient := l_adhoc_user_list;
3849 ELSE
3850 -- We send mass notifications to one ADHOC role which has the list of
3851 -- contact's workflow users.
3852 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
3853 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
3854 p_user_list => l_adhoc_user_list);
3855 l_notify_recipient := l_adhoc_role;
3856 END IF;
3857
3858 OPEN sel_jsp_name_csr;
3859 FETCH sel_jsp_name_csr INTO l_jsp_name;
3860 CLOSE sel_jsp_name_csr;
3861
3862 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
3863 || '?srID=' || l_request_number;
3864 WF_ENGINE.SetItemAttrText(
3865 itemtype => itemtype,
3866 itemkey => itemkey,
3867 aname => 'NTFY_REQUEST_NUMBER_URL',
3868 avalue => l_serviceRequest_URL);
3869
3870 ELSE
3871 l_notify_recipient := NULL;
3872 END IF;
3873
3874
3875 -- 11.5.10 enhancement to Create Interaction when email to contact sent.
3876 /* Roopa - begin bug 3360069 */
3877 /* Replacing the AddItemAttr() call with WF_Engine add, get and set calls
3878 to factor in the scenario where this attr already exists */
3879 IF (l_contact_party_id_list IS NOT NULL) THEN
3880
3881 OPEN check_if_item_attr_exists_csr;
3882 FETCH check_if_item_attr_exists_csr into l_temp_contact_id_list;
3883
3884 IF(check_if_item_attr_exists_csr%NOTFOUND) THEN
3885 WF_ENGINE.AddItemAttr( itemtype,
3886 itemkey,
3887 'CONTACT_PARTY_ID_LIST',
3888 l_contact_party_id_list);
3889 ELSE
3890 WF_ENGINE.SetItemAttrText(
3891 itemtype => itemtype,
3892 itemkey => itemkey,
3893 aname => 'CONTACT_PARTY_ID_LIST',
3894 avalue => l_contact_party_id_list);
3895 END IF;
3896 CLOSE check_if_item_attr_exists_csr;
3897
3898 END IF;
3899 /* Roopa - End bug 3360069 */
3900
3901 -- Start of code for Associated Party Notification -- Associated Party Added
3902 ELSIF (l_action_code = 'NOTIFY_NEW_ASSOCIATE_PARTY_ADD') THEN
3903
3904 l_contact_point_id_list := WF_ENGINE.GetItemAttrText(
3905 itemtype => itemtype,
3906 itemkey => itemkey,
3907 aname => 'NEW_ASSOCIATED_PARTY_ID_LIST' );
3908
3909 pull_from_list(itemlist => l_contact_point_id_list,
3910 element => l_element);
3911
3912 l_contact_email_list:= null;
3913
3914 WHILE l_element IS NOT NULL LOOP
3915
3916 l_contact_point_id := TO_NUMBER(l_element);
3917
3918 OPEN sel_new_party_role_contact_csr;
3919 FETCH sel_new_party_role_contact_csr
3920 INTO l_contact_email, l_contact_party_id, l_person_id, l_contact_type, l_tmp_contact_point_id,
3921 l_party_role_name, l_party_role_code;
3922
3923 WF_ENGINE.SetItemAttrText(
3924 itemtype => itemtype,
3925 itemkey => itemkey,
3926 aname => 'PARTY_ROLE_CODE',
3927 avalue => l_party_role_code);
3928
3929 WF_ENGINE.SetItemAttrText(
3930 itemtype => itemtype,
3931 itemkey => itemkey,
3932 aname => 'PARTY_ROLE_NAME',
3933 avalue => l_party_role_name);
3934
3935 IF (sel_new_party_role_contact_csr%FOUND OR l_contact_email IS NOT NULL)THEN
3936
3937 -- Check for WF email list length not to exceed 2000
3938 IF (nvl(LENGTH(l_contact_email_list), 0) + nvl(LENGTH(l_contact_email),0) + 1) <= 2000 THEN
3939
3940 IF (l_contact_email_list IS NULL) THEN
3941 l_contact_email_list := l_contact_email ;
3942 ELSE
3943 l_contact_email_list := l_contact_email_list ||','||l_contact_email;
3944 END IF;
3945
3946
3947 -- This section gets the workflow user of the contact, if none exist create an adhoc.
3948 IF (l_contact_type = 'EMPLOYEE') THEN
3949 l_orig_system := 'PER';
3950 l_orig_system_id := l_person_id;
3951 ELSE
3952 l_orig_system := 'HZ_PARTY';
3953 l_orig_system_id := l_contact_party_id;
3954 END IF;
3955
3956 OPEN c_user(l_orig_system,l_orig_system_id);
3957 FETCH c_user INTO l_user, l_user_display_name, l_email_address, l_notification_preference,l_language;
3958 CLOSE c_user;
3959
3960 -- If contact does not have workflow user, create an adhoc user.
3961 -- Adhoc user name is re-used for performance.
3962 -- The same party_id could have different contact info, but workflow schema
3963 -- only has one user/role which is the party in hz_party.
3964
3965 IF (l_user IS NULL OR
3966 (l_user is not null and instr(l_adhoc_user_list,l_user) > 0) OR
3967 (l_user is not null and l_email_address <> l_contact_email) ) THEN
3968
3969 adhoc_count := adhoc_count + 1;
3970
3971 l_user := 'CS_WF_CONTACT_USER_DUMMY' || to_char(adhoc_count) ;
3972
3973 -- need to pass display name also, other wise the 'To' field in mail and ntfxn
3974 -- will show the adhoc name.
3975 OPEN sel_contact_name_csr;
3976 FETCH sel_contact_name_csr INTO sel_contact_name_rec;
3977 l_user_display_name := sel_contact_name_rec.last_name || ', ' || sel_contact_name_rec.first_name;
3978 CLOSE sel_contact_name_csr;
3979
3980 SetWorkflowAdhocUser(p_wf_username => l_user,
3981 p_email_address => l_contact_email,
3982 p_display_name => l_user_display_name);
3983
3984 END IF;
3985
3986 IF (l_adhoc_user_list IS NULL) THEN
3987 l_adhoc_user_list := l_user ;
3988 ELSE
3989 l_adhoc_user_list := l_adhoc_user_list ||','||l_user;
3990 END IF;
3991
3992 -- 11.5.10 enhancement for create interaction when email to contact sent.
3993 IF (l_contact_party_id_list IS NULL) THEN
3994 l_contact_party_id_list := TO_CHAR(l_contact_party_id);
3995 ELSE
3996 l_contact_party_id_list := l_contact_party_id_list || ' '
3997 || TO_CHAR(l_contact_party_id);
3998 END IF;
3999 -- end 11.5.10 enhancement.
4000
4001 ELSE
4002 EXIT;
4003
4004 END IF;
4005 END IF;
4006 CLOSE sel_new_party_role_contact_csr;
4007
4008 pull_from_list(itemlist => l_contact_point_id_list,
4009 element => l_element);
4010
4011 END LOOP;
4012
4013 -- Fix for bug 3392429. Only create ADHOC role and notification if there
4014 -- is/are email addresses, since we send notifications for contacts via
4015 -- email . rmanabat 02/12/04 .
4016 IF (l_contact_email_list IS NOT NULL) THEN
4017
4018 -- If there's just one user in the list, then make the recipient that user.
4019 IF (instr(l_adhoc_user_list, ',') = 0) THEN
4020 l_notify_recipient := l_adhoc_user_list;
4021 ELSE
4022 -- We send mass notifications to one ADHOC role which has the list of
4023 -- contact's workflow users.
4024 l_adhoc_role := 'CS_WF_CONTACT_ROLE_DUMMY';
4025 SetWorkflowAdhocRole(p_wf_rolename => l_adhoc_role,
4026 p_user_list => l_adhoc_user_list);
4027 l_notify_recipient := l_adhoc_role;
4028 END IF;
4029
4030 OPEN sel_jsp_name_csr;
4031 FETCH sel_jsp_name_csr INTO l_jsp_name;
4032 CLOSE sel_jsp_name_csr;
4033
4034 l_serviceRequest_URL := FND_PROFILE.Value('JTF_BIS_OA_HTML') || '/' || l_jsp_name
4035 || '?srID=' || l_request_number;
4036 WF_ENGINE.SetItemAttrText(
4037 itemtype => itemtype,
4038 itemkey => itemkey,
4039 aname => 'NTFY_REQUEST_NUMBER_URL',
4040 avalue => l_serviceRequest_URL);
4041
4042 ELSE
4043 l_notify_recipient := NULL;
4044 END IF;
4045
4046 -- End of code for Associated Party Notification -- Associated Party Added
4047
4048 END IF; -- IF (l_action_code = 'NOTIFY_OWNER' OR .......
4049
4050 -- Get the message template to be used for the notification
4051 l_notification_template_id := WF_ENGINE.GetItemAttrText(
4052 itemtype => itemtype,
4053 itemkey => itemkey,
4054 aname => 'NTFY_MESSAGE_NAME');
4055
4056 IF (l_notify_recipient IS NOT NULL AND l_notification_template_id IS NOT NULL)THEN
4057
4058 IF l_html_notification_flag = 'Y' THEN
4059 result := 'COMPLETE:SET_HTML';
4060 ELSE
4061 result := 'COMPLETE:SET';
4062 END IF;
4063
4064 -- Set the recipient role for the notification
4065 WF_ENGINE.SetItemAttrText(
4066 itemtype => itemtype,
4067 itemkey => itemkey,
4068 aname => 'NTFY_RECIPIENT',
4069 avalue => l_notify_recipient);
4070
4071 ELSE
4072 result := 'COMPLETE:UNSET';
4073 END IF;
4074
4075 ELSIF (funmode = 'CANCEL') THEN
4076 result := 'COMPLETE';
4077 END IF;
4078
4079 EXCEPTION
4080 WHEN OTHERS THEN
4081 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Set_Notification_Details',
4082 itemtype, itemkey, actid, funmode);
4083 RAISE;
4084
4085 END Set_Notification_Details;
4086
4087
4088
4089 /******************************************************************
4090 -- Create_Contact_Interaction
4091 --
4092 ******************************************************************/
4093
4094 PROCEDURE Create_Contact_Interaction( itemtype IN VARCHAR2,
4095 itemkey IN VARCHAR2,
4096 actid IN NUMBER,
4097 funmode IN VARCHAR2,
4098 result OUT NOCOPY VARCHAR2 ) IS
4099
4100 l_contact_party_id_list VARCHAR2(2000);
4101 l_contact_party_id NUMBER;
4102 l_contact_party_name VARCHAR2(360);
4103 l_element VARCHAR2(100);
4104 l_request_id NUMBER;
4105 l_request_number VARCHAR2(64);
4106 l_user_id NUMBER;
4107 l_resp_appl_id NUMBER;
4108 l_login_id NUMBER;
4109 l_resp_id NUMBER;
4110
4111 l_owner_role VARCHAR2(320);
4112 l_error_role VARCHAR2(320);
4113
4114 l_msg_index_OUT NUMBER;
4115 l_error_text VARCHAR2(2000);
4116 NL VARCHAR2(1) := fnd_global.Local_Chr(10);
4117 x_return_status VARCHAR2(1);
4118 x_resource_id NUMBER;
4119 x_resource_type VARCHAR2(50);
4120 x_msg_count NUMBER;
4121 x_msg_data VARCHAR2(2000);
4122
4123
4124 CURSOR sel_contact_party_name_csr IS
4125 SELECT PARTY_NAME
4126 FROM HZ_PARTIES
4127 WHERE
4128 PARTY_ID = l_contact_party_id;
4129
4130 BEGIN
4131
4132 IF (funmode = 'RUN') THEN
4133
4134 l_contact_party_id_list := WF_ENGINE.GetItemAttrText(
4135 itemtype => itemtype,
4136 itemkey => itemkey,
4137 aname => 'CONTACT_PARTY_ID_LIST',
4138 ignore_notfound => TRUE);
4139
4140 IF (l_contact_party_id_list IS NULL) THEN
4141
4142 result := 'COMPLETE:NA';
4143
4144 ELSE
4145
4146 pull_from_list(itemlist => l_contact_party_id_list,
4147 element => l_element);
4148
4149 WF_ENGINE.SetItemAttrText(
4150 itemtype => itemtype,
4151 itemkey => itemkey,
4152 aname => 'CONTACT_PARTY_ID_LIST',
4153 avalue => l_contact_party_id_list );
4154
4155 l_contact_party_id := TO_NUMBER(l_element);
4156
4157 l_request_id := WF_ENGINE.GetItemAttrNumber(
4158 itemtype => itemtype,
4159 itemkey => itemkey,
4160 aname => 'REQUEST_ID' );
4161 l_request_number := WF_ENGINE.GetItemAttrText(
4162 itemtype => itemtype,
4163 itemkey => itemkey,
4164 aname => 'REQUEST_NUMBER' );
4165 l_user_id := WF_ENGINE.GetItemAttrNumber(
4166 itemtype => itemtype,
4167 itemkey => itemkey,
4168 aname => 'USER_ID' );
4169 l_resp_appl_id := WF_ENGINE.GetItemAttrNumber(
4170 itemtype => itemtype,
4171 itemkey => itemkey,
4172 aname => 'RESP_APPL_ID' );
4173 l_resp_id := WF_ENGINE.GetItemAttrNumber(
4174 itemtype => itemtype,
4175 itemkey => itemkey,
4176 aname => 'RESP_ID' );
4177
4178 l_owner_role := WF_ENGINE.GetItemAttrText(
4179 itemtype => itemtype,
4180 itemkey => itemkey,
4181 aname => 'OWNER_ROLE' );
4182
4183
4184 IF (FND_GLOBAL.LOGIN_ID NOT IN (-1,0)) THEN
4185 l_login_id := FND_GLOBAL.LOGIN_ID;
4186 ELSE
4187 l_login_id := NULL;
4188 END IF;
4189
4190
4191 --CS_WF_CONTACT_ACT_PKG.Create_Interaction_Activity(
4192 Create_Interaction_Activity(
4193 p_api_revision => 1.0,
4194 p_incident_id => l_request_id,
4195 p_incident_number => l_request_number,
4196 p_party_id => l_contact_party_id,
4197 p_user_id => l_user_id,
4198 p_resp_appl_id => l_resp_appl_id,
4199 p_resp_id => l_resp_id,
4200 p_login_id => l_login_id,
4201 x_return_status => x_return_status,
4202 x_resource_id => x_resource_id,
4203 x_resource_type => x_resource_type,
4204 x_msg_count => x_msg_count,
4205 x_msg_data => x_msg_data);
4206
4207 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4208
4209 result := 'COMPLETE:NOTCREATED';
4210
4211 IF ( FND_MSG_PUB.Count_Msg > 0) THEN
4212 FOR i IN 1..FND_MSG_PUB.Count_Msg LOOP
4213 FND_MSG_PUB.Get(p_msg_index => i,
4214 p_encoded => 'F',
4215 p_data => x_msg_data,
4216 p_msg_index_OUT => l_msg_index_OUT );
4217 l_error_text := l_error_text || x_msg_data ||NL;
4218 END LOOP;
4219 END IF;
4220
4221 WF_ENGINE.SetItemAttrText(
4222 itemtype => itemtype,
4223 itemkey => itemkey,
4224 aname => 'INTERACTION_ERR_DATA',
4225 avalue => l_error_text );
4226
4227 OPEN sel_contact_party_name_csr;
4228 FETCH sel_contact_party_name_csr INTO l_contact_party_name;
4229 CLOSE sel_contact_party_name_csr;
4230
4231 WF_ENGINE.SetItemAttrText(
4232 itemtype => itemtype,
4233 itemkey => itemkey,
4234 aname => 'INTERACTION_PARTY_NAME',
4235 avalue => l_contact_party_name );
4236
4237 -- Part of fix for bug 3360069. rmanabat 01/19/04.
4238 IF (l_owner_role is NOT NULL) THEN
4239 l_error_role := l_owner_role;
4240 ELSE
4241 l_error_role := 'SYSADMIN';
4242 END IF;
4243 WF_ENGINE.SetItemAttrText(
4244 itemtype => itemtype,
4245 itemkey => itemkey,
4246 aname => 'INTERACTION_ERROR_ROLE',
4247 avalue => l_error_role );
4248
4249 ELSE
4250 result := 'COMPLETE:CREATED';
4251 END IF;
4252
4253
4254 END IF; -- IF (l_contact_party_id_list IS NOT NULL)
4255
4256
4257 ELSIF (funmode = 'CANCEL') THEN
4258 result := 'COMPLETE';
4259 END IF;
4260
4261
4262 EXCEPTION
4263 WHEN OTHERS THEN
4264 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Create_Contact_Interaction',
4265 itemtype, itemkey, actid, funmode);
4266 RAISE;
4267
4268 END Create_Contact_Interaction;
4269
4270
4271 /******************************************************************
4272 -- All_Interactions_Created
4273 --
4274 ******************************************************************/
4275
4276 PROCEDURE All_Interactions_Created( itemtype IN VARCHAR2,
4277 itemkey IN VARCHAR2,
4278 actid IN NUMBER,
4279 funmode IN VARCHAR2,
4280 result OUT NOCOPY VARCHAR2 ) IS
4281
4282 l_contact_party_id_list VARCHAR2(2000);
4283
4284
4285 BEGIN
4286
4287 IF (funmode = 'RUN') THEN
4288
4289 l_contact_party_id_list := WF_ENGINE.GetItemAttrText(
4290 itemtype => itemtype,
4291 itemkey => itemkey,
4292 aname => 'CONTACT_PARTY_ID_LIST',
4293 ignore_notfound => TRUE);
4294
4295 IF (l_contact_party_id_list IS NULL) THEN
4296 result := 'COMPLETE:Y';
4297 ELSE
4298 result := 'COMPLETE:N';
4299 END IF;
4300
4301
4302 ELSIF (funmode = 'CANCEL') THEN
4303 result := 'COMPLETE';
4304 END IF;
4305
4306
4307 EXCEPTION
4308 WHEN OTHERS THEN
4309 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'All_Interactions_Created',
4310 itemtype, itemkey, actid, funmode);
4311 RAISE;
4312
4313 END All_Interactions_Created;
4314
4315
4316 /******************************************************************
4317 -- All_Recipients_Notified
4318 --
4319 -- This procedure corresponds to the VRFY_NTFY_LIST_DONE function
4320 -- activity.
4321 --
4322 -- This procedure checks if all the recipients of the related
4323 -- service requests have been notified. If all the related SRs
4324 -- did not fit in the initial list, then we will have to build
4325 -- another list here to determine the recipients of the ntfxn.
4326 ******************************************************************/
4327
4328 PROCEDURE All_Recipients_Notified( itemtype IN VARCHAR2,
4329 itemkey IN VARCHAR2,
4330 actid IN NUMBER,
4331 funmode IN VARCHAR2,
4332 result OUT NOCOPY VARCHAR2 ) IS
4333
4334 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
4335 l_linked_subject_list VARCHAR2(4000);
4336 l_overflow_flag VARCHAR2(1);
4337 l_relationship_type_id CS_SR_ACTION_DETAILS.relationship_type_id%TYPE;
4338 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
4339 l_char_subject_id VARCHAR2(30);
4340 l_subject_id NUMBER;
4341 l_request_number VARCHAR2(64);
4342 l_request_id NUMBER;
4343
4344 l_notify_relsr_party_role_list VARCHAR2(2000);
4345 l_notify_party_role_list VARCHAR2(2000);
4346
4347
4348 CURSOR sel_event_action_csr IS
4349 SELECT csad.event_condition_id,
4350 csad.action_code,
4351 csad.notification_template_id, /** this is the WF message name **/
4352 csad.relationship_type_id detail_link_type
4353 FROM CS_SR_ACTION_DETAILS csad
4354 WHERE csad.event_condition_id = l_event_condition_id
4355 and csad.action_code = l_action_code
4356 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
4357 and TRUNC(NVL(csad.end_date_active, SYSDATE))
4358 and csad.notification_template_id IS NOT NULL
4359 and csad.action_code like 'NOTIFY%';
4360
4361 sel_event_action_rec sel_event_action_csr%ROWTYPE;
4362
4363
4364 CURSOR sel_link_csr_1 IS
4365 SELECT
4366 cil.object_id,
4367 cil.link_id,
4368 inc.incident_owner_id
4369 FROM cs_incident_links cil,
4370 cs_incidents_all_b inc
4371 WHERE cil.subject_id = l_request_id
4372 and inc.incident_id = cil.object_id
4373 and cil.object_id > l_subject_id
4374 ORDER BY cil.object_id;
4375
4376 CURSOR sel_link_csr_2 IS
4377 SELECT
4378 cil.object_id,
4379 cil.link_id,
4380 inc.incident_owner_id
4381 FROM cs_incident_links cil,
4382 cs_incidents_all_b inc
4383 WHERE cil.subject_id = l_request_id
4384 AND cil.link_type_id = l_relationship_type_id
4385 AND inc.incident_id = cil.object_id
4386 and cil.object_id > l_subject_id
4387 ORDER BY cil.object_id;
4388
4389 sel_link_rec sel_link_csr_1%ROWTYPE;
4390
4391 BEGIN
4392
4393 IF (funmode = 'RUN') THEN
4394
4395 l_action_code := WF_ENGINE.GetItemAttrText(
4396 itemtype => itemtype,
4397 itemkey => itemkey,
4398 aname => 'NTFY_ACTION_CODE' );
4399
4400 IF (l_action_code = 'NOTIFY_OWNER_OF_RELATED_SR') OR
4401 (l_action_code = 'NOTIFY_PRIM_CONTACT_OF_REL_SR') OR
4402 (l_action_code = 'NOTIFY_ALL_CONTACTS_OF_REL_SR') THEN
4403
4404 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
4405 itemtype => itemtype,
4406 itemkey => itemkey,
4407 aname => 'NTFY_LINKED_SUBJECT_LIST');
4408
4409 IF (l_linked_subject_list IS NOT NULL) THEN
4410
4411 result := 'COMPLETE:N';
4412
4413 ELSE
4414
4415 l_overflow_flag := WF_ENGINE.GetItemAttrText(
4416 itemtype => itemtype,
4417 itemkey => itemkey,
4418 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST');
4419
4420 IF (l_overflow_flag = 'Y') THEN
4421
4422 -- Reset the Overflow flag
4423 WF_ENGINE.SetItemAttrText(
4424 itemtype => itemtype,
4425 itemkey => itemkey,
4426 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST',
4427 avalue => '' );
4428
4429 l_event_condition_id := WF_ENGINE.GetItemAttrNumber(
4430 itemtype => itemtype,
4431 itemkey => itemkey,
4432 aname => 'NTFY_EVENT_CONDITION_ID' );
4433
4434 l_subject_id := WF_ENGINE.GetItemAttrNumber(
4435 itemtype => itemtype,
4436 itemkey => itemkey,
4437 aname => 'NTFY_SUBJECT_ID');
4438
4439 l_request_number := WF_ENGINE.GetItemAttrText(
4440 itemtype => itemtype,
4441 itemkey => itemkey,
4442 aname => 'REQUEST_NUMBER' );
4443
4444 l_request_id := WF_ENGINE.GetItemAttrNumber(
4445 itemtype => itemtype,
4446 itemkey => itemkey,
4447 aname => 'REQUEST_ID' );
4448
4449 IF (sel_event_action_rec.detail_link_type IS NOT NULL) THEN
4450 l_relationship_type_id := sel_event_action_rec.detail_link_type;
4451 OPEN sel_link_csr_2;
4452 ELSE
4453 OPEN sel_link_csr_1;
4454 END IF;
4455
4456 LOOP
4457 IF (sel_event_action_rec.detail_link_type IS NOT NULL) THEN
4458 FETCH sel_link_csr_2 INTO sel_link_rec;
4459 EXIT WHEN sel_link_csr_2%NOTFOUND;
4460 ELSE
4461 FETCH sel_link_csr_1 INTO sel_link_rec;
4462 EXIT WHEN sel_link_csr_1%NOTFOUND;
4463 END IF;
4464
4465 l_char_subject_id := TO_CHAR(sel_link_rec.object_id);
4466
4467 IF ((nvl(LENGTH(l_linked_subject_list),0) +
4468 nvl(LENGTH(l_char_subject_id),0) + 1) <= 4000) THEN
4469 IF l_linked_subject_list IS NULL THEN
4470 l_linked_subject_list := l_char_subject_id;
4471 ELSE
4472 l_linked_subject_list := l_linked_subject_list || ' ' || l_char_subject_id;
4473 END IF;
4474 ELSE /**** Will need to build another list later since it won't fit here ***/
4475 WF_ENGINE.SetItemAttrText(
4476 itemtype => itemtype,
4477 itemkey => itemkey,
4478 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST',
4479 avalue => 'Y' );
4480 EXIT;
4481 END IF;
4482
4483 END LOOP;
4484
4485 IF sel_link_csr_2%ISOPEN THEN
4486 CLOSE sel_link_csr_2;
4487 ELSIF sel_link_csr_1%ISOPEN THEN
4488 CLOSE sel_link_csr_1;
4489 END IF;
4490
4491 IF (l_linked_subject_list IS NOT NULL) THEN
4492
4493 WF_ENGINE.SetItemAttrText(
4494 itemtype => itemtype,
4495 itemkey => itemkey,
4496 aname => 'NTFY_LINKED_SUBJECT_LIST',
4497 avalue => l_linked_subject_list );
4498
4499 result := 'COMPLETE:N';
4500 ELSE
4501 result := 'COMPLETE:Y';
4502 END IF;
4503 ELSE /*** IF (l_overflow_flag = 'Y') ***/
4504 result := 'COMPLETE:Y';
4505 END IF;
4506
4507 END IF; /*** IF (l_linked_subject_list IS NOT NULL) ***/
4508
4509 ELSIF (l_action_code = 'NOTIFY_ALL_ASSOCIATED_PARTIES') THEN
4510
4511 l_notify_relsr_party_role_list := WF_ENGINE.GetItemAttrText(
4512 itemtype => itemtype,
4513 itemkey => itemkey,
4514 aname => 'NOTIFY_RELSR_PARTY_ROLE_LIST');
4515
4516 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
4517 itemtype => itemtype,
4518 itemkey => itemkey,
4519 aname => 'NTFY_LINKED_SUBJECT_LIST');
4520
4521 IF (l_linked_subject_list IS NOT NULL or l_notify_relsr_party_role_list IS NOT NULL) THEN
4522
4523 result := 'COMPLETE:N';
4524
4525 ELSE
4526
4527 l_overflow_flag := WF_ENGINE.GetItemAttrText(
4528 itemtype => itemtype,
4529 itemkey => itemkey,
4530 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST');
4531
4532 IF (l_overflow_flag = 'Y') THEN
4533
4534 -- Reset the Overflow flag
4535 WF_ENGINE.SetItemAttrText(
4536 itemtype => itemtype,
4537 itemkey => itemkey,
4538 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST',
4539 avalue => '' );
4540
4541 l_event_condition_id := WF_ENGINE.GetItemAttrNumber(
4542 itemtype => itemtype,
4543 itemkey => itemkey,
4544 aname => 'NTFY_EVENT_CONDITION_ID' );
4545
4546 l_subject_id := WF_ENGINE.GetItemAttrNumber(
4547 itemtype => itemtype,
4548 itemkey => itemkey,
4549 aname => 'NTFY_SUBJECT_ID');
4550
4551 l_request_number := WF_ENGINE.GetItemAttrText(
4552 itemtype => itemtype,
4553 itemkey => itemkey,
4554 aname => 'REQUEST_NUMBER' );
4555
4556 l_request_id := WF_ENGINE.GetItemAttrNumber(
4557 itemtype => itemtype,
4558 itemkey => itemkey,
4559 aname => 'REQUEST_ID' );
4560
4561 IF (sel_event_action_rec.detail_link_type IS NOT NULL) THEN
4562 l_relationship_type_id := sel_event_action_rec.detail_link_type;
4563 OPEN sel_link_csr_2;
4564 ELSE
4565 OPEN sel_link_csr_1;
4566 END IF;
4567
4568 LOOP
4569 IF (sel_event_action_rec.detail_link_type IS NOT NULL) THEN
4570 FETCH sel_link_csr_2 INTO sel_link_rec;
4571 EXIT WHEN sel_link_csr_2%NOTFOUND;
4572 ELSE
4573 FETCH sel_link_csr_1 INTO sel_link_rec;
4574 EXIT WHEN sel_link_csr_1%NOTFOUND;
4575 END IF;
4576
4577 l_char_subject_id := TO_CHAR(sel_link_rec.object_id);
4578
4579 IF ((nvl(LENGTH(l_linked_subject_list),0) +
4580 nvl(LENGTH(l_char_subject_id),0) + 1) <= 4000) THEN
4581 IF l_linked_subject_list IS NULL THEN
4582 l_linked_subject_list := l_char_subject_id;
4583 ELSE
4584 l_linked_subject_list := l_linked_subject_list || ' ' || l_char_subject_id;
4585 END IF;
4586 ELSE /**** Will need to build another list later since it won't fit here ***/
4587 WF_ENGINE.SetItemAttrText(
4588 itemtype => itemtype,
4589 itemkey => itemkey,
4590 aname => 'MORE_NTFY_LINKED_SUBJECT_LIST',
4591 avalue => 'Y' );
4592 EXIT;
4593 END IF;
4594
4595 END LOOP;
4596
4597 IF sel_link_csr_2%ISOPEN THEN
4598 CLOSE sel_link_csr_2;
4599 ELSIF sel_link_csr_1%ISOPEN THEN
4600 CLOSE sel_link_csr_1;
4601 END IF;
4602
4603 IF (l_linked_subject_list IS NOT NULL) THEN
4604
4605 WF_ENGINE.SetItemAttrText(
4606 itemtype => itemtype,
4607 itemkey => itemkey,
4608 aname => 'NTFY_LINKED_SUBJECT_LIST',
4609 avalue => l_linked_subject_list );
4610
4611 result := 'COMPLETE:N';
4612 ELSE
4613 result := 'COMPLETE:Y';
4614 END IF;
4615 ELSE /*** IF (l_overflow_flag = 'Y') ***/
4616 result := 'COMPLETE:Y';
4617 END IF;
4618
4619 END IF; /*** IF (l_linked_subject_list IS NOT NULL) ***/
4620
4621 ELSIF (l_action_code = 'NOTIFY_ASSOCIATED_PARTIES') THEN
4622 l_notify_party_role_list := WF_ENGINE.GetItemAttrText(
4623 itemtype => itemtype,
4624 itemkey => itemkey,
4625 aname => 'NOTIFY_PARTY_ROLE_LIST');
4626
4627 IF (l_notify_party_role_list IS NOT NULL) THEN
4628 result := 'COMPLETE:N';
4629 ELSE
4630 result := 'COMPLETE:Y';
4631 END IF;
4632
4633 ELSE /*** IF (l_action_code = 'NOTIFY_OWNER_OF_RELATED_SR') ***/
4634 result := 'COMPLETE:Y';
4635 END IF;
4636
4637 ELSIF (funmode = 'CANCEL') THEN
4638 result := 'COMPLETE';
4639 END IF;
4640
4641 EXCEPTION
4642 WHEN OTHERS THEN
4643 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'All_Recipients_Notified',
4644 itemtype, itemkey, actid, funmode);
4645 RAISE;
4646
4647 END All_Recipients_Notified;
4648
4649
4650 /***************************************************************************
4651 -- Verify_Notify_Rules_Done
4652 --
4653 -- This procedure corresponds to the VRFY_NEW_STATUS function
4654 -- activity.
4655 --
4656 -- This procedure checks if all the notification rules has been executed.
4657 -- We will have to build a new rules list if there was an overflow
4658 -- (as indicated by the MORE_NTFY_ACTION_LIST flag) because there are
4659 -- more rules in the query.
4660 **************************************************************************/
4661
4662 PROCEDURE Verify_Notify_Rules_Done( itemtype IN VARCHAR2,
4663 itemkey IN VARCHAR2,
4664 actid IN NUMBER,
4665 funmode IN VARCHAR2,
4666 result OUT NOCOPY VARCHAR2 ) IS
4667
4668 l_event_name VARCHAR2(240);
4669 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
4670 l_char_event_condition_id VARCHAR2(30);
4671
4672 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
4673 l_notify_conditions_list VARCHAR2(4000);
4674 l_notify_actions_list VARCHAR2(4000);
4675 l_overflow_flag VARCHAR2(1);
4676
4677
4678 CURSOR sel_action_csr IS
4679 SELECT csad.event_condition_id,
4680 csad.action_code,
4681 csad.notification_template_id
4682 FROM CS_SR_ACTION_TRIGGERS csat,
4683 CS_SR_ACTION_DETAILS csad,
4684 CS_SR_EVENT_CODES_B cec
4685 WHERE
4686 cec.WF_BUSINESS_EVENT_ID = l_event_name
4687 and csat.EVENT_CODE = cec.EVENT_CODE
4688 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
4689 and TRUNC(NVL(csat.end_date_active, SYSDATE))
4690 and csad.event_condition_id = csat.event_condition_id
4691 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
4692 and TRUNC(NVL(csad.end_date_active, SYSDATE))
4693 and csad.notification_template_id IS NOT NULL
4694 and csad.action_code like 'NOTIFY%'
4695 AND TO_CHAR(csad.event_condition_id) || csad.action_code >
4696 TO_CHAR(l_event_condition_id) || l_action_code
4697 ORDER BY TO_CHAR(1) || 2;
4698
4699 sel_action_rec sel_action_csr%ROWTYPE;
4700
4701
4702 BEGIN
4703
4704 IF (funmode = 'RUN') THEN
4705
4706 l_notify_conditions_list := WF_ENGINE.GetItemAttrText(
4707 itemtype => itemtype,
4708 itemkey => itemkey,
4709 aname => 'NTFY_CONDITION_LIST' );
4710
4711 l_notify_actions_list := WF_ENGINE.GetItemAttrText(
4712 itemtype => itemtype,
4713 itemkey => itemkey,
4714 aname => 'NTFY_ACTION_LIST' );
4715
4716 IF (l_notify_conditions_list IS NOT NULL AND l_notify_actions_list IS NOT NULL) THEN
4717 result := 'COMPLETE:N';
4718 ELSE
4719
4720 l_overflow_flag := WF_ENGINE.GetItemAttrText(
4721 itemtype => itemtype,
4722 itemkey => itemkey,
4723 aname => 'MORE_NTFY_ACTION_LIST');
4724
4725 IF (l_overflow_flag = 'Y') THEN
4726
4727 -- Reset the Overflow flag
4728 WF_ENGINE.SetItemAttrText(
4729 itemtype => itemtype,
4730 itemkey => itemkey,
4731 aname => 'MORE_NTFY_ACTION_LIST',
4732 avalue => '' );
4733
4734 l_event_condition_id := WF_ENGINE.GetItemAttrNumber(
4735 itemtype => itemtype,
4736 itemkey => itemkey,
4737 aname => 'NTFY_EVENT_CONDITION_ID');
4738 l_action_code := WF_ENGINE.GetItemAttrText(
4739 itemtype => itemtype,
4740 itemkey => itemkey,
4741 aname => 'NTFY_ACTION_CODE');
4742 l_event_name := WF_ENGINE.GetItemAttrText(
4743 itemtype => itemtype,
4744 itemkey => itemkey,
4745 aname => 'EVENTNAME' );
4746
4747 OPEN sel_action_csr;
4748 LOOP
4749 FETCH sel_action_csr INTO sel_action_rec;
4750 EXIT WHEN sel_action_csr%NOTFOUND;
4751 l_char_event_condition_id := TO_CHAR(sel_action_rec.event_condition_id);
4752
4753 IF (nvl(LENGTH(l_notify_conditions_list),0) +
4754 nvl(LENGTH(l_char_event_condition_id),0) + 1) <= 4000 OR
4755 (nvl(LENGTH(l_notify_actions_list),0) +
4756 nvl(LENGTH(sel_action_rec.action_code),0) + 1 ) <= 4000 THEN
4757
4758 IF l_notify_conditions_list IS NULL THEN
4759 l_notify_conditions_list := l_char_event_condition_id;
4760 l_notify_actions_list := sel_action_rec.action_code;
4761 ELSE
4762 l_notify_conditions_list := l_notify_conditions_list || ' ' || l_char_event_condition_id;
4763 l_notify_actions_list := l_notify_actions_list || ' ' || sel_action_rec.action_code;
4764 END IF;
4765 ELSE
4766
4767 WF_ENGINE.SetItemAttrText(
4768 itemtype => itemtype,
4769 itemkey => itemkey,
4770 aname => 'MORE_NTFY_ACTION_LIST',
4771 avalue => 'Y' );
4772 EXIT;
4773
4774 END IF;
4775 END LOOP;
4776 CLOSE sel_action_csr;
4777
4778 IF (l_notify_conditions_list IS NOT NULL AND l_notify_actions_list IS NOT NULL) THEN
4779
4780 WF_ENGINE.SetItemAttrText(
4781 itemtype => itemtype,
4782 itemkey => itemkey,
4783 aname => 'NTFY_CONDITION_LIST',
4784 avalue => l_notify_conditions_list );
4785 WF_ENGINE.SetItemAttrText(
4786 itemtype => itemtype,
4787 itemkey => itemkey,
4788 aname => 'NTFY_ACTION_LIST',
4789 avalue => l_notify_actions_list );
4790
4791 result := 'COMPLETE:N';
4792 ELSE
4793 result := 'COMPLETE:Y';
4794 END IF;
4795
4796
4797 ELSE /** IF (l_overflow_flag = 'Y') **/
4798
4799 result := 'COMPLETE:Y';
4800
4801 END IF;
4802
4803
4804 /** IF (l_update_conditions_list IS NOT NULL AND l_update_actions_list IS NOT NULL) **/
4805 END IF;
4806
4807
4808 ELSIF (funmode = 'CANCEL') THEN
4809 result := 'COMPLETE';
4810 END IF;
4811
4812 EXCEPTION
4813 WHEN OTHERS THEN
4814 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Verify_Notify_Rules_Done',
4815 itemtype, itemkey, actid, funmode);
4816 RAISE;
4817
4818 END Verify_Notify_Rules_Done;
4819
4820
4821 /*****************************************************************************
4822 -- Check_Status_Rules
4823 --
4824 -- This procedure corresponds to the CHECK_STATUS_RULES function
4825 -- activity.
4826 --
4827 -- The procedure checks if there are update rules defined by checking
4828 -- the conditions/actions list. If the list is not empty, then we pull the
4829 -- first item on the lists to process. Otherwise, we end the sub-process.
4830 --
4831 *****************************************************************************/
4832
4833 PROCEDURE Check_Status_Rules( itemtype IN VARCHAR2,
4834 itemkey IN VARCHAR2,
4835 actid IN NUMBER,
4836 funmode IN VARCHAR2,
4837 result OUT NOCOPY VARCHAR2 ) IS
4838
4839 l_event_action VARCHAR2(50);
4840 l_actions_list VARCHAR2(4000);
4841 --l_link_id CS_INCIDENT_LINKS.LINK_ID%TYPE;
4842 --l_subject_id CS_INCIDENT_LINKS.SUBJECT_ID%TYPE;
4843 --l_link_type_code CS_INCIDENT_LINKS.LINK_TYPE_CODE%TYPE;
4844
4845 l_update_conditions_list VARCHAR2(4000);
4846 l_update_actions_list VARCHAR2(4000);
4847 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
4848 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
4849
4850 l_space_pos NUMBER;
4851 l_element VARCHAR2(100);
4852
4853
4854 BEGIN
4855
4856 IF (funmode = 'RUN') THEN
4857
4858 l_update_conditions_list := WF_ENGINE.GetItemAttrText(
4859 itemtype => itemtype,
4860 itemkey => itemkey,
4861 aname => 'UPDATE_CONDITION_LIST' );
4862
4863 l_update_actions_list := WF_ENGINE.GetItemAttrText(
4864 itemtype => itemtype,
4865 itemkey => itemkey,
4866 aname => 'UPDATE_ACTION_LIST' );
4867
4868 IF (l_update_conditions_list IS NOT NULL AND l_update_actions_list IS NOT NULL) THEN
4869
4870 pull_from_list(itemlist => l_update_conditions_list,
4871 element => l_element);
4872 l_event_condition_id := TO_NUMBER(l_element);
4873
4874 pull_from_list(itemlist => l_update_actions_list,
4875 element => l_action_code);
4876
4877 IF (l_event_condition_id IS NOT NULL AND l_action_code IS NOT NULL) THEN
4878 WF_ENGINE.SetItemAttrText(
4879 itemtype => itemtype,
4880 itemkey => itemkey,
4881 aname => 'UPDATE_CONDITION_LIST',
4882 avalue => l_update_conditions_list );
4883 WF_ENGINE.SetItemAttrText(
4884 itemtype => itemtype,
4885 itemkey => itemkey,
4886 aname => 'UPDATE_ACTION_LIST',
4887 avalue => l_update_actions_list );
4888 WF_ENGINE.SetItemAttrNumber(
4889 itemtype => itemtype,
4890 itemkey => itemkey,
4891 aname => 'UPDATE_EVENT_CONDITION_ID',
4892 avalue => l_event_condition_id );
4893 WF_ENGINE.SetItemAttrText(
4894 itemtype => itemtype,
4895 itemkey => itemkey,
4896 aname => 'UPDATE_ACTION_CODE',
4897 avalue => l_action_code );
4898
4899 result := 'COMPLETE:Y';
4900
4901 ELSE
4902 result := 'COMPLETE:N';
4903
4904 END IF;
4905
4906 ELSE
4907 result := 'COMPLETE:N';
4908 END IF;
4909
4910 ELSIF (funmode = 'CANCEL') THEN
4911 result := 'COMPLETE';
4912 END IF;
4913
4914 EXCEPTION
4915 WHEN OTHERS THEN
4916 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Check_Status_Rules',
4917 itemtype, itemkey, actid, funmode);
4918 RAISE;
4919
4920 END Check_Status_Rules;
4921
4922
4923 /****************************************************************************
4924 -- Get_Links_For_Rule
4925 --
4926 -- This procedure corresponds to the GET_STATUS_PROPAGATION_RULES function
4927 -- activity.
4928 --
4929 -- This procedure builds a list of related service requests that satisfy
4930 -- the update rule being processed.
4931 ****************************************************************************/
4932
4933 PROCEDURE Get_Links_For_Rule( itemtype IN VARCHAR2,
4934 itemkey IN VARCHAR2,
4935 actid IN NUMBER,
4936 funmode IN VARCHAR2,
4937 result OUT NOCOPY VARCHAR2 ) IS
4938
4939 l_event_name VARCHAR2(240);
4940 l_event_action VARCHAR2(50);
4941 l_actions_list VARCHAR2(4000);
4942 --l_link_id VARCHAR2(20);
4943
4944 --l_subject_id CS_INCIDENT_LINKS.SUBJECT_ID%TYPE;
4945 l_subject_id VARCHAR2(30);
4946 --l_link_type_code CS_INCIDENT_LINKS.LINK_TYPE_CODE%TYPE;
4947 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
4948 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
4949
4950 l_new_request_status VARCHAR2(30);
4951 l_old_request_status VARCHAR2(30);
4952 l_request_status VARCHAR2(30);
4953 l_request_status_temp VARCHAR2(30);
4954 l_request_number VARCHAR2(64);
4955 l_relationship_type_id CS_SR_ACTION_DETAILS.relationship_type_id%TYPE;
4956 l_relationship_type_name VARCHAR2(240);
4957 l_linked_subject_list VARCHAR2(4000);
4958
4959 l_request_id NUMBER;
4960
4961 /* 03/01/2004 - RHUNGUND - Bug fix for 3412852
4962 Changed the order of the FROM clause since the optimization rules indicate that
4963 a cartesian join occurs if :
4964 1) If a join condition is missing for the FROM clause tables
4965 2) If the FROM clause is not listing the tables in the proper order
4966
4967 */
4968 CURSOR sel_event_action_csr IS
4969 SELECT csat.relationship_type_id trigger_link_type,
4970 csat.from_to_status_code,
4971 csat.incident_status_id trigger_incident_status_id,
4972 csad.relationship_type_id detail_link_type,
4973 csad.incident_status_id detail_incident_status_id,
4974 csad.resolution_code
4975 FROM CS_SR_EVENT_CODES_B cec,
4976 CS_SR_ACTION_TRIGGERS csat,
4977 CS_SR_ACTION_DETAILS csad
4978 WHERE
4979 cec.WF_BUSINESS_EVENT_ID = l_event_name
4980 and cec.EVENT_CODE = csat.EVENT_CODE
4981 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
4982 and TRUNC(NVL(csat.end_date_active, SYSDATE))
4983 and csat.event_condition_id = csad.event_condition_id
4984 and csad.event_condition_id = l_event_condition_id
4985 and csad.action_code = l_action_code
4986 and csad.action_code NOT like 'NOTIFY%'
4987 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
4988 and TRUNC(NVL(csad.end_date_active, SYSDATE));
4989
4990
4991
4992
4993 sel_event_action_rec sel_event_action_csr%ROWTYPE;
4994
4995 CURSOR sel_link_csr IS
4996 SELECT cil.link_type_id,
4997 cil.object_id,
4998 cil.link_id
4999 FROM cs_incident_links cil
5000 WHERE cil.subject_id = l_request_id
5001 AND cil.link_type_id = l_relationship_type_id
5002 ORDER BY cil.object_id;
5003
5004 sel_link_rec sel_link_csr%ROWTYPE;
5005
5006 BEGIN
5007
5008 IF (funmode = 'RUN') THEN
5009
5010 l_request_number := WF_ENGINE.GetItemAttrText(
5011 itemtype => itemtype,
5012 itemkey => itemkey,
5013 aname => 'REQUEST_NUMBER' );
5014
5015 l_request_id := WF_ENGINE.GetItemAttrNumber(
5016 itemtype => itemtype,
5017 itemkey => itemkey,
5018 aname => 'REQUEST_ID' );
5019
5020 l_event_name := WF_ENGINE.GetItemAttrText(
5021 itemtype => itemtype,
5022 itemkey => itemkey,
5023 aname => 'EVENTNAME' );
5024
5025 l_event_condition_id := WF_ENGINE.GetItemAttrNumber(
5026 itemtype => itemtype,
5027 itemkey => itemkey,
5028 aname => 'UPDATE_EVENT_CONDITION_ID' );
5029
5030 l_action_code := WF_ENGINE.GetItemAttrText(
5031 itemtype => itemtype,
5032 itemkey => itemkey,
5033 aname => 'UPDATE_ACTION_CODE' );
5034
5035 OPEN sel_event_action_csr;
5036 FETCH sel_event_action_csr INTO sel_event_action_rec;
5037 CLOSE sel_event_action_csr;
5038
5039 IF (sel_event_action_rec.from_to_status_code IS NOT NULL) THEN
5040
5041 IF (sel_event_action_rec.from_to_status_code = 'STATUS_CHANGED_TO') THEN
5042 l_request_status := WF_ENGINE.GetItemAttrText(
5043 itemtype => itemtype,
5044 itemkey => itemkey,
5045 aname => 'REQUEST_STATUS' );
5046 ELSIF (sel_event_action_rec.from_to_status_code = 'STATUS_CHANGED_FROM') THEN
5047 l_request_status := WF_ENGINE.GetItemAttrText(
5048 itemtype => itemtype,
5049 itemkey => itemkey,
5050 aname => 'REQUEST_STATUS_OLD' );
5051 END IF;
5052
5053 SELECT name
5054 INTO l_request_status_temp
5055 FROM CS_INCIDENT_STATUSES_VL
5056 WHERE INCIDENT_STATUS_ID = sel_event_action_rec.trigger_incident_status_id;
5057
5058 IF (l_request_status = l_request_status_temp) THEN
5059 WF_ENGINE.SetItemAttrNumber(
5060 itemtype => itemtype,
5061 itemkey => itemkey,
5062 aname => 'SUBJECT_STATUS_ID',
5063 avalue => sel_event_action_rec.detail_incident_status_id );
5064
5065 ELSE
5066 WF_ENGINE.SetItemAttrText(
5067 itemtype => itemtype,
5068 itemkey => itemkey,
5069 aname => 'SUBJECT_STATUS_ID',
5070 avalue => NULL);
5071 END IF;
5072
5073 l_relationship_type_id := sel_event_action_rec.detail_link_type;
5074
5075
5076 ELSIF (sel_event_action_rec.trigger_link_type IS NOT NULL) THEN
5077 WF_ENGINE.SetItemAttrNumber(
5078 itemtype => itemtype,
5079 itemkey => itemkey,
5080 aname => 'SUBJECT_STATUS_ID',
5081 avalue => sel_event_action_rec.detail_incident_status_id );
5082
5083 WF_ENGINE.SetItemAttrText(
5084 itemtype => itemtype,
5085 itemkey => itemkey,
5086 aname => 'SUBJECT_RESOLUTION_CODE',
5087 avalue => sel_event_action_rec.resolution_code );
5088
5089 l_relationship_type_id := sel_event_action_rec.trigger_link_type;
5090
5091 END IF;
5092
5093 -- Obtain link type name from relationship_type_id
5094 SELECT name
5095 INTO l_relationship_type_name
5096 FROM CS_SR_LINK_TYPES_VL
5097 WHERE link_type_id = l_relationship_type_id;
5098
5099 WF_ENGINE.SetItemAttrText(
5100 itemtype => itemtype,
5101 itemkey => itemkey,
5102 aname => 'UPDATE_RELATIONSHIP_TYPE',
5103 avalue => l_relationship_type_name);
5104
5105 -- Select All Links with the link_type_code and create a subject_id list in workflow.
5106 -- It is guaranteed that every Rule in the list has existing Link SR, this was taken care of
5107 -- when building the initial Rule list in Check_Rules_For_Event().
5108 OPEN sel_link_csr;
5109 LOOP
5110 FETCH sel_link_csr INTO sel_link_rec;
5111 EXIT WHEN sel_link_csr%NOTFOUND;
5112 l_subject_id := TO_CHAR(sel_link_rec.object_id);
5113
5114 IF ((nvl(LENGTH(l_linked_subject_list),0) + nvl(LENGTH(l_subject_id),0) + 1) <= 4000) THEN
5115
5116 IF l_linked_subject_list IS NULL THEN
5117 l_linked_subject_list := l_subject_id;
5118 ELSE
5119 l_linked_subject_list := l_linked_subject_list || ' ' || l_subject_id;
5120 END IF;
5121 ELSE
5122
5123 WF_ENGINE.SetItemAttrText(
5124 itemtype => itemtype,
5125 itemkey => itemkey,
5126 aname => 'MORE_UPDT_LINKED_SUBJECT_LIST',
5127 avalue => 'Y' );
5128 EXIT;
5129
5130 END IF;
5131
5132 END LOOP;
5133 CLOSE sel_link_csr;
5134
5135 IF (l_linked_subject_list IS NOT NULL) THEN
5136 WF_ENGINE.SetItemAttrText(
5137 itemtype => itemtype,
5138 itemkey => itemkey,
5139 aname => 'UPDATE_LINKED_SUBJECT_LIST',
5140 avalue => l_linked_subject_list );
5141
5142 result := 'COMPLETE:Y';
5143
5144 ELSE
5145 result := 'COMPLETE:N';
5146 END IF;
5147
5148 ELSIF (funmode = 'CANCEL') THEN
5149 result := 'COMPLETE';
5150 END IF;
5151
5152 EXCEPTION
5153 WHEN OTHERS THEN
5154 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Get_Links_For_Rule',
5155 itemtype, itemkey, actid, funmode);
5156 RAISE;
5157
5158 END Get_Links_For_Rule;
5159
5160
5161
5162 /****************************************************************************
5163 -- Execute_Rules_Per_SR
5164 --
5165 -- This procedure corresponds to the GET_STATUS_PROPAGATION_RULES function
5166 -- activity.
5167 --
5168 -- This procedure iterates through the list of related service requests and
5169 -- sets the first item on the list to be processed.
5170 ****************************************************************************/
5171
5172 PROCEDURE Execute_Rules_Per_SR( itemtype IN VARCHAR2,
5173 itemkey IN VARCHAR2,
5174 actid IN NUMBER,
5175 funmode IN VARCHAR2,
5176 result OUT NOCOPY VARCHAR2 ) IS
5177
5178 --l_subject_id CS_INCIDENT_LINKS.SUBJECT_ID%TYPE;
5179 --l_subject_id VARCHAR2(30);
5180
5181 l_linked_subject_list VARCHAR2(4000);
5182 l_element VARCHAR2(100);
5183
5184 BEGIN
5185
5186 IF (funmode = 'RUN') THEN
5187
5188 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
5189 itemtype => itemtype,
5190 itemkey => itemkey,
5191 aname => 'UPDATE_LINKED_SUBJECT_LIST' );
5192
5193 pull_from_list(itemlist => l_linked_subject_list,
5194 element => l_element);
5195
5196 WF_ENGINE.SetItemAttrNumber(
5197 itemtype => itemtype,
5198 itemkey => itemkey,
5199 aname => 'UPDATE_SUBJECT_ID',
5200 avalue => TO_NUMBER(l_element) );
5201
5202 WF_ENGINE.SetItemAttrText(
5203 itemtype => itemtype,
5204 itemkey => itemkey,
5205 aname => 'UPDATE_LINKED_SUBJECT_LIST',
5206 avalue => l_linked_subject_list );
5207
5208 result := 'COMPLETE';
5209
5210 ELSIF (funmode = 'CANCEL') THEN
5211 result := 'COMPLETE';
5212 END IF;
5213
5214 EXCEPTION
5215 WHEN OTHERS THEN
5216 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Execute_Rules_Per_SR',
5217 itemtype, itemkey, actid, funmode);
5218 RAISE;
5219
5220 END Execute_Rules_Per_SR;
5221
5222
5223 /****************************************************************************
5224 -- Verify_Update_Valid
5225 --
5226 -- This procedure corresponds to the VRFY_NEW_STATUS function
5227 -- activity.
5228 --
5229 -- This procedure checks if the update being done is valid. The rules are:
5230 -- 1.) If the SR which needs to be updated has a status with
5231 -- 'closed flag' ON, DO NOT update the status of the service request.
5232 -- 2.) During automatic update, workflow process should not close a
5233 -- service request if it has outgoing links of type
5234 -- duplicate of/caused by to open service requests.
5235 --
5236 -- Modification History:
5237 --
5238 -- Date Name Desc
5239 -- ---------- --------- ---------------------------------------------
5240 -- 05/11/04 RMANABAT Fix for bug 3582873. Validate if the incoming status
5241 -- is either 'Clear' or 'Close' as per SRD.
5242 -- 06/15/04 RMANABAT Fix for bug 3690121. Changed cursor sel_related_sr_cur
5243 -- to look at inc.status_flag instead of the status
5244 -- close_flag. Also validated just 'Caused By' link
5245 -- to allow close of SR when 'Duplicate Of' link is
5246 -- created.
5247 ****************************************************************************/
5248
5249 PROCEDURE Verify_Update_Valid( itemtype IN VARCHAR2,
5250 itemkey IN VARCHAR2,
5251 actid IN NUMBER,
5252 funmode IN VARCHAR2,
5253 result OUT NOCOPY VARCHAR2 ) IS
5254
5255 l_subject_id CS_INCIDENT_LINKS.SUBJECT_ID%TYPE;
5256 --l_link_type_code CS_INCIDENT_LINKS.LINK_TYPE_CODE%TYPE;
5257 l_subject_status_id CS_SR_ACTION_DETAILS.incident_status_id%TYPE;
5258 l_resolution_code CS_SR_ACTION_DETAILS.resolution_code%TYPE;
5259 l_close_flag VARCHAR2(1);
5260 l_link_id CS_INCIDENT_LINKS.LINK_ID%TYPE;
5261
5262 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
5263 l_sr_updated NUMBER;
5264 l_incident_status_id NUMBER;
5265 l_UNHANDLED_ACTION EXCEPTION;
5266
5267 --l_err_txt VARCHAR2(30);
5268
5269 CURSOR sel_related_sr_cur(lv_incident_id IN NUMBER) IS
5270 SELECT cil.link_id
5271 FROM cs_incident_links cil,
5272 cs_incidents_all_b inc
5273 WHERE cil.subject_id = lv_incident_id
5274 -- Hard coded values for 'CAUSED BY' (2) and 'DUPLICATE OF' (3).
5275 AND cil.link_type_id = 2
5276 AND cil.object_id = inc.incident_id
5277 AND inc.status_flag = 'O' ;
5278
5279 CURSOR sel_close_flag_csr(lv_incident_id IN NUMBER) IS
5280 SELECT nvl(status.close_flag,'N'),
5281 inc.incident_status_id
5282 FROM cs_incident_statuses status, cs_incidents_all_b inc
5283 WHERE inc.incident_id = lv_incident_id
5284 AND inc.incident_status_id = status.incident_status_id;
5285
5286 BEGIN
5287
5288 IF (funmode = 'RUN') THEN
5289
5290 -- SUBJECT_STATUS_ID can be null when updating resolution code . Update Rule #3.
5291 l_subject_status_id := WF_ENGINE.GetItemAttrNumber(
5292 itemtype => itemtype,
5293 itemkey => itemkey,
5294 aname => 'SUBJECT_STATUS_ID' );
5295
5296 --l_err_txt := 'Valid1';
5297
5298 l_resolution_code := WF_ENGINE.GetItemAttrText(
5299 itemtype => itemtype,
5300 itemkey => itemkey,
5301 aname => 'SUBJECT_RESOLUTION_CODE' );
5302
5303 IF (l_subject_status_id IS NULL AND l_resolution_code IS NULL) THEN
5304 result := 'COMPLETE:N';
5305
5306 ELSE
5307
5308 l_subject_id := WF_ENGINE.GetItemAttrNumber(
5309 itemtype => itemtype,
5310 itemkey => itemkey,
5311 aname => 'UPDATE_SUBJECT_ID' );
5312
5313 l_action_code := WF_ENGINE.GetItemAttrText(
5314 itemtype => itemtype,
5315 itemkey => itemkey,
5316 aname => 'UPDATE_ACTION_CODE' );
5317
5318 IF (l_action_code = 'CHANGE_SR_STATUS' OR l_action_code = 'CHANGE_SR_RESOLUTION') THEN
5319 l_sr_updated := WF_ENGINE.GetItemAttrNumber(
5320 itemtype => itemtype,
5321 itemkey => itemkey,
5322 aname => 'REQUEST_ID' );
5323 ELSIF (l_action_code = 'CHANGE_RELATED_SR_STATUS') THEN
5324 l_sr_updated := l_subject_id;
5325 ELSE
5326 raise l_UNHANDLED_ACTION;
5327 END IF;
5328
5329 --l_err_txt := 'Valid2';
5330
5331 OPEN sel_close_flag_csr(l_sr_updated);
5332 FETCH sel_close_flag_csr
5333 INTO l_close_flag, l_incident_status_id;
5334 CLOSE sel_close_flag_csr;
5335
5336 /**********************************************
5337 If the SR which needs to be updated has a status
5338 with 'closed flag' ON, DO NOT update the status
5339 of the service request.
5340 **********************************************/
5341 IF (l_close_flag = 'Y' OR l_incident_status_id = l_subject_status_id) THEN
5342 result := 'COMPLETE:N';
5343 ELSE
5344
5345 /********************************************
5346 During automatic update, workflow process should
5347 not close a service request if it has outgoing
5348 links of type duplicate of/caused by to open
5349 service requests.
5350 ********************************************/
5351
5352 IF (l_subject_status_id IS NULL) THEN -- Updating resolution code only, not status.
5353
5354 result := 'COMPLETE:Y';
5355
5356 ELSE -- Updating Status
5357
5358
5359 IF (l_subject_status_id = 101) THEN
5360 l_close_flag := 'Y';
5361 ELSE
5362 SELECT nvl(status.close_flag,'N')
5363 INTO l_close_flag
5364 FROM cs_incident_statuses status
5365 WHERE status.incident_status_id = l_subject_status_id;
5366 END IF;
5367
5368 IF (l_close_flag = 'Y') THEN
5369 OPEN sel_related_sr_cur(l_sr_updated);
5370 FETCH sel_related_sr_cur INTO l_link_id;
5371 IF (sel_related_sr_cur%FOUND) THEN
5372 result := 'COMPLETE:N';
5373 ELSE
5374 result := 'COMPLETE:Y';
5375 END IF;
5376 CLOSE sel_related_sr_cur;
5377 ELSE
5378 result := 'COMPLETE:Y';
5379 END IF;
5380
5381 END IF; -- IF (l_subject_status_id IS NULL)
5382
5383 END IF;
5384
5385 END IF;
5386
5387
5388 ELSIF (funmode = 'CANCEL') THEN
5389 result := 'COMPLETE';
5390 END IF;
5391
5392 EXCEPTION
5393 WHEN l_UNHANDLED_ACTION THEN
5394 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Verify_Update_Valid',
5395 itemtype, itemkey, actid, funmode);
5396 RAISE;
5397 WHEN OTHERS THEN
5398 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Verify_Update_Valid',
5399 itemtype, itemkey, actid, funmode);
5400 RAISE;
5401
5402 END Verify_Update_Valid;
5403
5404
5405 /*************************************************************************
5406 -- Update_SR
5407 --
5408 -- This procedure corresponds to the VRFY_NEW_STATUS function
5409 -- activity.
5410 --
5411 -- This procedure makes the call to Update_Sericerequest() api to update
5412 -- the status or resolution code of the SR, as defined in the update
5413 -- rule.
5414 -- Depending on the result of the update api call, we set the transition :
5415 -- 1. FND_API.G_RET_STS_SUCCESS - we set the renult to 'UPDATED'.
5416 -- We then move on and process the next related service request.
5417 -- 2. 'L'- we set the result to 'LOCKED'. If the record is locked, We
5418 -- then wait for 10 secs and re-try updating the record. We attempt
5419 -- the update 5 times, each time waiting 10 secs. if the record is
5420 -- still locked. If after 5 tries we still can't update, then we set
5421 -- the result to 'FAILED' (item 3).
5422 -- 3. Otherwise (update failed) - we set the result to 'FAILED'. We
5423 -- then try to send a notification to the owner of the SR we are
5424 -- updating with the error message stack.
5425 -- Modification History:
5426 --
5427 -- Date Name Desc
5428 -- -------- ---------- --------------------------------------
5429 -- 05/25/2004 RMANABAT Fix for bug 3612904. Passed resp_id and
5430 -- rep_appL_id to update_servicerequest() api
5431 -- for security validation.
5432 *************************************************************************/
5433
5434 PROCEDURE Update_SR( itemtype IN VARCHAR2,
5435 itemkey IN VARCHAR2,
5436 actid IN NUMBER,
5437 funmode IN VARCHAR2,
5438 result OUT NOCOPY VARCHAR2 ) IS
5439
5440 l_request_number VARCHAR2(64);
5441 l_request_id NUMBER;
5442 l_subject_id CS_INCIDENT_LINKS.SUBJECT_ID%TYPE;
5443 l_subject_status_id CS_SR_ACTION_DETAILS.incident_status_id%TYPE;
5444 l_resolution_code CS_SR_ACTION_DETAILS.resolution_code%TYPE;
5445 l_service_request_rec CS_ServiceRequest_PVT.service_request_rec_type;
5446 l_object_version_number NUMBER;
5447 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
5448
5449 --l_request_id NUMBER;
5450 l_subject_owner_id NUMBER;
5451 l_close_flag VARCHAR2(1);
5452 l_return_status VARCHAR2(1);
5453 l_msg_count NUMBER;
5454 l_msg_data VARCHAR2(2000);
5455 l_user_id NUMBER;
5456 l_notes CS_SERVICEREQUEST_PVT.notes_table;
5457 l_contacts CS_SERVICEREQUEST_PVT.contacts_table;
5458 out_interaction_id number;
5459 out_wf_process_id number;
5460
5461 l_UNHANDLED_ACTION EXCEPTION;
5462
5463 l_error_text VARCHAR2(2000);
5464 NL VARCHAR2(1);
5465 l_msg_index_OUT NUMBER;
5466 l_wf_process_id NUMBER;
5467
5468 l_resp_appl_id NUMBER;
5469 l_resp_id NUMBER;
5470
5471 CURSOR sel_incident_from_number_csr IS
5472 SELECT object_version_number, incident_owner_id, incident_id
5473 FROM cs_incidents_all_b
5474 WHERE incident_number = l_request_number;
5475
5476
5477 CURSOR sel_incident_from_id_csr IS
5478 SELECT object_version_number, incident_owner_id
5479 FROM cs_incidents_all_b
5480 WHERE incident_id = l_subject_id;
5481
5482
5483 BEGIN
5484
5485 NL := fnd_global.Local_Chr(10);
5486
5487 IF (funmode = 'RUN') THEN
5488
5489
5490 CS_ServiceRequest_PVT.initialize_rec(l_service_request_rec);
5491
5492 l_action_code := WF_ENGINE.GetItemAttrText(
5493 itemtype => itemtype,
5494 itemkey => itemkey,
5495 aname => 'UPDATE_ACTION_CODE' );
5496
5497 l_request_number := WF_ENGINE.GetItemAttrText(
5498 itemtype => itemtype,
5499 itemkey => itemkey,
5500 aname => 'REQUEST_NUMBER' );
5501
5502 l_user_id := WF_ENGINE.GetItemAttrNumber(
5503 itemtype => itemtype,
5504 itemkey => itemkey,
5505 aname => 'USER_ID' );
5506
5507 l_subject_status_id := WF_ENGINE.GetItemAttrNumber(
5508 itemtype => itemtype,
5509 itemkey => itemkey,
5510 aname => 'SUBJECT_STATUS_ID' );
5511
5512 l_resolution_code := WF_ENGINE.GetItemAttrText(
5513 itemtype => itemtype,
5514 itemkey => itemkey,
5515 aname => 'SUBJECT_RESOLUTION_CODE' );
5516
5517 l_subject_id := WF_ENGINE.GetItemAttrNumber(
5518 itemtype => itemtype,
5519 itemkey => itemkey,
5520 aname => 'UPDATE_SUBJECT_ID' );
5521
5522 IF (l_action_code = 'CHANGE_SR_STATUS' OR l_action_code = 'CHANGE_SR_RESOLUTION') THEN
5523
5524 OPEN sel_incident_from_number_csr;
5525 FETCH sel_incident_from_number_csr
5526 INTO l_object_version_number, l_subject_owner_id, l_request_id;
5527 CLOSE sel_incident_from_number_csr;
5528
5529 ELSIF (l_action_code = 'CHANGE_RELATED_SR_STATUS') THEN
5530
5531 OPEN sel_incident_from_id_csr;
5532 FETCH sel_incident_from_id_csr
5533 INTO l_object_version_number, l_subject_owner_id;
5534 CLOSE sel_incident_from_id_csr;
5535
5536 l_request_id := l_subject_id;
5537
5538 ELSE
5539 RAISE l_UNHANDLED_ACTION;
5540 END IF;
5541
5542 IF (l_subject_status_id IS NOT NULL) THEN
5543 l_service_request_rec.status_id := l_subject_status_id;
5544
5545 SELECT nvl(status.close_flag,'N')
5546 INTO l_close_flag
5547 FROM cs_incident_statuses status
5548 WHERE status.incident_status_id = l_subject_status_id;
5549
5550 IF (l_close_flag = 'Y') THEN
5551 l_service_request_rec.closed_date := sysdate;
5552 END IF;
5553
5554 END IF;
5555
5556 IF (l_resolution_code IS NOT NULL) THEN
5557 l_service_request_rec.resolution_code := l_resolution_code;
5558 END IF;
5559
5560 l_service_request_rec.last_update_program_code := 'SUPPORT.WF';
5561
5562 --l_wf_process_id := TO_NUMBER(substr(itemkey, instr(itemkey,'-')+1));
5563
5564 l_resp_appl_id := WF_ENGINE.GetItemAttrNumber(
5565 itemtype => itemtype,
5566 itemkey => itemkey,
5567 aname => 'RESP_APPL_ID' );
5568 l_resp_id := WF_ENGINE.GetItemAttrNumber(
5569 itemtype => itemtype,
5570 itemkey => itemkey,
5571 aname => 'RESP_ID' );
5572
5573 CS_ServiceRequest_PVT.Update_ServiceRequest
5574 ( p_api_version => 3.0,
5575 p_init_msg_list => fnd_api.g_false,
5576 p_commit => fnd_api.g_true,
5577 p_validation_level => fnd_api.g_valid_level_full,
5578 x_return_status => l_return_status,
5579 x_msg_count => l_msg_count,
5580 x_msg_data => l_msg_data,
5581 p_request_id => l_request_id,
5582 --p_request_id => l_subject_id,
5583 p_last_updated_by => l_user_id,
5584 p_last_update_date => sysdate,
5585 p_service_request_rec => l_service_request_rec,
5586 p_notes => l_notes,
5587 p_contacts => l_contacts,
5588 p_object_version_number=> l_object_version_number,
5589 p_resp_appl_id => l_resp_appl_id,
5590 p_resp_id => l_resp_id,
5591 --p_workflow_process_id => l_wf_process_id,
5592 x_interaction_id => out_interaction_id,
5593 x_workflow_process_id => out_wf_process_id
5594 );
5595
5596 -- Check for possible errors returned by the API
5597 IF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
5598 result := 'COMPLETE:UPDATED';
5599 -- We need to have a separate return status for locked row exception.
5600 ELSIF (l_return_status = 'L') THEN
5601 --ELSIF (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
5602 result := 'COMPLETE:LOCKED';
5603 ELSE
5604 -- Obtain the owner role of the related SR being updated, and set-up the
5605 -- the notification to be sent to the owner of the SR.
5606 result := 'COMPLETE:FAILED';
5607 END IF;
5608
5609
5610 -- IF (l_msg_data is not null) THEN
5611 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
5612
5613
5614 IF ( FND_MSG_PUB.Count_Msg > 0) THEN
5615 FOR i IN 1..FND_MSG_PUB.Count_Msg LOOP
5616 FND_MSG_PUB.Get(p_msg_index => i,
5617 p_encoded => 'F',
5618 p_data => l_msg_data,
5619 p_msg_index_OUT => l_msg_index_OUT );
5620 l_error_text := l_error_text || l_msg_data ||NL;
5621 END LOOP;
5622 END IF;
5623
5624
5625 WF_ENGINE.SetItemAttrText(
5626 itemtype => itemtype,
5627 itemkey => itemkey,
5628 aname => 'UPDATE_ERROR_DATA',
5629 avalue => l_error_text );
5630 END IF;
5631
5632
5633
5634 /*****************************************
5635 FND_MSG_PUB.Count_And_Get( p_count => l_msg_count,
5636 p_data => l_msg_data,
5637 p_encoded => FND_API.G_FALSE );
5638 wf_core.context( pkg_name => 'CS_ServiceRequest_PUB',
5639 proc_name => 'Update_Status',
5640 arg1 => 'p_user_id=>'||l_user_id,
5641 arg2 => 'p_org_id=>'||l_org_id,
5642 arg3 => 'p_request_number=>'||l_request_number,
5643 arg4 => 'p_status_id=>'||l_new_status_id,
5644 arg5 => 'p_msg_data=>'||l_msg_data );
5645 l_errmsg_name := 'CS_SR_CANT_UPDATE_STATUS';
5646 raise l_API_ERROR;
5647 ******************************************/
5648
5649 ELSIF (funmode = 'CANCEL') THEN
5650 result := 'COMPLETE';
5651 END IF;
5652
5653 EXCEPTION
5654 WHEN l_UNHANDLED_ACTION THEN
5655 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Update_SR',
5656 itemtype, itemkey, actid, funmode);
5657 RAISE;
5658
5659 WHEN OTHERS THEN
5660 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Update_SR',
5661 itemtype, itemkey, actid, funmode);
5662 RAISE;
5663
5664 END Update_SR;
5665
5666
5667 /********************************************************************
5668 -- Set_Notify_Error
5669 -- This procedure corresponds to the SET_NTFY_ERROR_DETAILS function
5670 -- activity.
5671 -- This procedure sets the notification details for sending the
5672 -- error message when the update activity failed.
5673 ********************************************************************/
5674
5675 PROCEDURE Set_Notify_Error( itemtype IN VARCHAR2,
5676 itemkey IN VARCHAR2,
5677 actid IN NUMBER,
5678 funmode IN VARCHAR2,
5679 result OUT NOCOPY VARCHAR2 ) IS
5680
5681 l_request_number VARCHAR2(64);
5682 l_request_id NUMBER;
5683 l_subject_id CS_INCIDENT_LINKS.SUBJECT_ID%TYPE;
5684 l_subject_status_id CS_SR_ACTION_DETAILS.incident_status_id%TYPE;
5685 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
5686 l_subject_owner_id NUMBER;
5687
5688 l_return_status VARCHAR2(1);
5689 l_msg_count NUMBER;
5690 l_msg_data VARCHAR2(2000);
5691 l_owner_role VARCHAR2(100);
5692 l_owner_name VARCHAR2(240);
5693
5694 CURSOR l_cs_sr_get_empid_csr IS
5695 SELECT inc.incident_number, emp.source_id
5696 FROM jtf_rs_resource_extns emp ,
5697 cs_incidents_all_b inc
5698 WHERE emp.resource_id = inc.incident_owner_id
5699 AND inc.incident_id = l_subject_id;
5700
5701 BEGIN
5702
5703 IF (funmode = 'RUN') THEN
5704
5705 l_action_code := WF_ENGINE.GetItemAttrText(
5706 itemtype => itemtype,
5707 itemkey => itemkey,
5708 aname => 'UPDATE_ACTION_CODE' );
5709
5710 l_request_number := WF_ENGINE.GetItemAttrText(
5711 itemtype => itemtype,
5712 itemkey => itemkey,
5713 aname => 'REQUEST_NUMBER' );
5714
5715 l_subject_id := WF_ENGINE.GetItemAttrNumber(
5716 itemtype => itemtype,
5717 itemkey => itemkey,
5718 aname => 'UPDATE_SUBJECT_ID' );
5719
5720 IF (l_action_code = 'CHANGE_SR_STATUS' OR l_action_code = 'CHANGE_SR_RESOLUTION') THEN
5721
5722 l_owner_role := WF_ENGINE.GetItemAttrText(
5723 itemtype => itemtype,
5724 itemkey => itemkey,
5725 aname => 'OWNER_ROLE' );
5726
5727 ELSIF (l_action_code = 'CHANGE_RELATED_SR_STATUS') THEN
5728
5729 /*************
5730 SELECT incident_number, incident_owner_id
5731 INTO l_request_number, l_subject_owner_id
5732 FROM cs_incidents_all_b
5733 WHERE incident_id = l_subject_id;
5734
5735 IF (l_subject_owner_id IS NULL)THEN
5736 l_owner_role := NULL;
5737 ELSE
5738 *************/
5739
5740 OPEN l_cs_sr_get_empid_csr;
5741 FETCH l_cs_sr_get_empid_csr
5742 INTO l_request_number, l_subject_owner_id;
5743
5744 IF( l_cs_sr_get_empid_csr%NOTFOUND OR l_subject_owner_id IS NULL) THEN
5745 l_owner_role := NULL;
5746 ELSE
5747
5748 -- Retrieve the role name for the request owner
5749 CS_WORKFLOW_PUB.Get_Employee_Role (
5750 p_api_version => 1.0,
5751 p_return_status => l_return_status,
5752 p_msg_count => l_msg_count,
5753 p_msg_data => l_msg_data,
5754 --p_employee_id => l_subject_id,
5755 p_employee_id => l_subject_owner_id,
5756 p_role_name => l_owner_role,
5757 p_role_display_name => l_owner_name );
5758 END IF;
5759 CLOSE l_cs_sr_get_empid_csr;
5760
5761 END IF;
5762
5763 If (l_owner_role IS NOT NULL) THEN
5764
5765 WF_ENGINE.SetItemAttrText(
5766 itemtype => itemtype,
5767 itemkey => itemkey,
5768 aname => 'UPDATE_REQUEST_ROLE',
5769 avalue => l_owner_role );
5770
5771 WF_ENGINE.SetItemAttrText(
5772 itemtype => itemtype,
5773 itemkey => itemkey,
5774 aname => 'UPDATE_REQUEST_NUMBER',
5775 avalue => l_request_number );
5776
5777 result := 'COMPLETE:SET';
5778
5779 ELSE
5780 result := 'COMPLETE:UNSET';
5781 END IF;
5782
5783
5784 ELSIF (funmode = 'CANCEL') THEN
5785 result := 'COMPLETE';
5786 END IF;
5787
5788 EXCEPTION
5789 WHEN OTHERS THEN
5790 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Set_Notify_Error',
5791 itemtype, itemkey, actid, funmode);
5792 RAISE;
5793
5794 END Set_Notify_Error;
5795
5796
5797 /***********************************************************************
5798 -- Verify_All_Links_Done
5799 -- This procedure corresponds to the VRFY_NEW_STATUS function
5800 -- activity.
5801 -- The procedure verifies if the Linked Service Request list has
5802 -- been exhausted. If not then the procedure returns an 'N' which
5803 -- tells the workflow to process the next rule on the list.
5804 -- If the list has been exhausted, we check if the list overload flag
5805 -- is set to 'Y' (which means the initial list did not fit all the
5806 -- queried rows), if it is not then we return a 'Y' telling the
5807 -- workflow that all Linked Service Requests has been processed.
5808 -- If the overflow flag is 'Y', then we build another list
5809 -- starting from the next linked incident_id (object_id) item of
5810 -- the last item on the previous list.
5811 **********************************************************************/
5812
5813 PROCEDURE Verify_All_Links_Done( itemtype IN VARCHAR2,
5814 itemkey IN VARCHAR2,
5815 actid IN NUMBER,
5816 funmode IN VARCHAR2,
5817 result OUT NOCOPY VARCHAR2 ) IS
5818
5819 l_linked_subject_list VARCHAR2(4000);
5820 --l_link_type_code CS_INCIDENT_LINKS.LINK_TYPE_CODE%TYPE;
5821 --l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
5822 --l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
5823 l_relationship_type_id CS_SR_ACTION_DETAILS.relationship_type_id%TYPE;
5824 l_relationship_type_name VARCHAR2(240);
5825 l_subject_id NUMBER;
5826 l_char_subject_id VARCHAR2(30);
5827 l_request_number VARCHAR2(64);
5828 l_request_id NUMBER;
5829
5830 l_overflow_flag VARCHAR2(1);
5831
5832 CURSOR sel_link_csr IS
5833 SELECT cil.link_type_id,
5834 cil.object_id,
5835 cil.link_id
5836 FROM cs_incident_links cil,
5837 CS_SR_LINK_TYPES_VL cilt
5838 WHERE cil.subject_id = l_request_id
5839 AND cil.link_type_id = cilt.link_type_id
5840 AND cilt.name = l_relationship_type_name
5841 AND cil.object_id > l_subject_id
5842 ORDER BY cil.object_id;
5843
5844 sel_link_rec sel_link_csr%ROWTYPE;
5845
5846 BEGIN
5847
5848 IF (funmode = 'RUN') THEN
5849
5850 l_linked_subject_list := WF_ENGINE.GetItemAttrText(
5851 itemtype => itemtype,
5852 itemkey => itemkey,
5853 aname => 'UPDATE_LINKED_SUBJECT_LIST' );
5854
5855 IF (l_linked_subject_list IS NOT NULL) THEN
5856 result := 'COMPLETE:N';
5857 ELSE
5858
5859 l_overflow_flag := WF_ENGINE.GetItemAttrText(
5860 itemtype => itemtype,
5861 itemkey => itemkey,
5862 aname => 'MORE_UPDT_LINKED_SUBJECT_LIST');
5863
5864 IF (l_overflow_flag = 'Y') THEN
5865
5866 -- Reset the Overflow flag
5867 WF_ENGINE.SetItemAttrText(
5868 itemtype => itemtype,
5869 itemkey => itemkey,
5870 aname => 'MORE_UPDT_LINKED_SUBJECT_LIST',
5871 avalue => '' );
5872
5873 l_request_number := WF_ENGINE.GetItemAttrText(
5874 itemtype => itemtype,
5875 itemkey => itemkey,
5876 aname => 'REQUEST_NUMBER' );
5877 l_request_id := WF_ENGINE.GetItemAttrNumber(
5878 itemtype => itemtype,
5879 itemkey => itemkey,
5880 aname => 'REQUEST_ID' );
5881 l_relationship_type_name := WF_ENGINE.GetItemAttrText(
5882 itemtype => itemtype,
5883 itemkey => itemkey,
5884 aname => 'UPDATE_RELATIONSHIP_TYPE');
5885 l_subject_id := WF_ENGINE.GetItemAttrNumber(
5886 itemtype => itemtype,
5887 itemkey => itemkey,
5888 aname => 'UPDATE_SUBJECT_ID');
5889
5890 OPEN sel_link_csr;
5891 LOOP
5892 FETCH sel_link_csr INTO sel_link_rec;
5893 EXIT WHEN sel_link_csr%NOTFOUND;
5894 l_char_subject_id := TO_CHAR(sel_link_rec.object_id);
5895
5896 IF ((nvl(LENGTH(l_linked_subject_list),0) +
5897 nvl(LENGTH(l_char_subject_id),0) + 1) <= 4000) THEN
5898
5899 IF l_linked_subject_list IS NULL THEN
5900 l_linked_subject_list := l_char_subject_id;
5901 ELSE
5902 l_linked_subject_list := l_linked_subject_list || ' ' || l_char_subject_id;
5903 END IF;
5904 ELSE
5905 WF_ENGINE.SetItemAttrText(
5906 itemtype => itemtype,
5907 itemkey => itemkey,
5908 aname => 'MORE_UPDT_LINKED_SUBJECT_LIST',
5909 avalue => 'Y' );
5910 EXIT;
5911
5912 END IF;
5913
5914 END LOOP;
5915 CLOSE sel_link_csr;
5916
5917 IF (l_linked_subject_list IS NOT NULL) THEN
5918 WF_ENGINE.SetItemAttrText(
5919 itemtype => itemtype,
5920 itemkey => itemkey,
5921 aname => 'UPDATE_LINKED_SUBJECT_LIST',
5922 avalue => l_linked_subject_list );
5923
5924 result := 'COMPLETE:N';
5925 ELSE
5926 result := 'COMPLETE:Y';
5927 END IF;
5928 ELSE /*** IF (l_overflow_flag = 'Y') ***/
5929 result := 'COMPLETE:Y';
5930 END IF;
5931
5932
5933 END IF; /** IF (l_linked_subject_list IS NOT NULL) **/
5934
5935 ELSIF (funmode = 'CANCEL') THEN
5936 result := 'COMPLETE';
5937 END IF;
5938
5939 EXCEPTION
5940 WHEN OTHERS THEN
5941 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Verify_All_Links_Done',
5942 itemtype, itemkey, actid, funmode);
5943 RAISE;
5944
5945 END Verify_All_Links_Done;
5946
5947
5948 /*************************************************************************
5949 -- Verify_Update_Rules_Done
5950 -- This procedure corresponds to the VRFY_NEW_STATUS function
5951 -- activity.
5952 -- The procedure verifies if the Update Rules (conditions + actions is
5953 -- unique) list has been exhausted. If not then the procedure returns
5954 -- an 'N' which tells the workflow to process the next rule on the list.
5955 -- If the list has been exhausted, we check if the list overload flag
5956 -- is set to 'Y' (which means the initial list did not fit all the
5957 -- queried rows), if it is not then we return a 'Y' telling the
5958 -- workflow that all update rules has been processed. If the overflow
5959 -- flag is 'Y', then we build another list starting from the next
5960 -- condition+action item of the last item on the previous list.
5961 ************************************************************************/
5962
5963 PROCEDURE Verify_Update_Rules_Done( itemtype IN VARCHAR2,
5964 itemkey IN VARCHAR2,
5965 actid IN NUMBER,
5966 funmode IN VARCHAR2,
5967 result OUT NOCOPY VARCHAR2 ) IS
5968
5969 l_update_conditions_list VARCHAR2(4000);
5970 l_update_actions_list VARCHAR2(4000);
5971 l_event_name VARCHAR2(240);
5972 --l_action_code VARCHAR2(30);
5973 l_request_number VARCHAR2(64);
5974 l_event_condition_id CS_SR_ACTION_TRIGGERS.event_condition_id%TYPE;
5975 l_char_event_condition_id VARCHAR2(30);
5976 l_action_code CS_SR_ACTION_DETAILS.action_code%TYPE;
5977
5978 l_overflow_flag VARCHAR2(1);
5979 l_request_id NUMBER;
5980
5981 CURSOR sel_action_csr IS
5982 SELECT csad.event_condition_id,
5983 csad.action_code,
5984 to_char(csad.event_condition_id) || csad.action_code index_cols
5985 FROM CS_SR_ACTION_TRIGGERS csat,
5986 CS_SR_ACTION_DETAILS csad,
5987 CS_SR_EVENT_CODES_B cec
5988 WHERE
5989 cec.WF_BUSINESS_EVENT_ID = l_event_name
5990 and csat.EVENT_CODE = cec.EVENT_CODE
5991 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
5992 and TRUNC(NVL(csat.end_date_active, SYSDATE))
5993 and csad.event_condition_id = csat.event_condition_id
5994 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
5995 and TRUNC(NVL(csad.end_date_active, SYSDATE))
5996 and csat.from_to_status_code IS NULL
5997 and csad.action_code NOT like 'NOTIFY%'
5998 and (csad.incident_status_id IS NOT NULL OR
5999 csad.resolution_code IS NOT NULL)
6000 and csat.relationship_type_id IN
6001 ( select cil.link_type_id
6002 FROM cs_incident_links cil
6003 WHERE cil.subject_id = l_request_id)
6004 AND TO_CHAR(csad.event_condition_id) || csad.action_code >
6005 TO_CHAR(l_event_condition_id) || l_action_code
6006 UNION
6007 SELECT csad.event_condition_id,
6008 csad.action_code,
6009 to_char(csad.event_condition_id) || csad.action_code index_cols
6010 FROM CS_SR_ACTION_TRIGGERS csat,
6011 CS_SR_ACTION_DETAILS csad,
6012 CS_SR_EVENT_CODES_B cec
6013 WHERE
6014 cec.WF_BUSINESS_EVENT_ID = l_event_name
6015 and csat.EVENT_CODE = cec.EVENT_CODE
6016 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csat.start_date_active, SYSDATE))
6017 and TRUNC(NVL(csat.end_date_active, SYSDATE))
6018 and csad.event_condition_id = csat.event_condition_id
6019 and TRUNC(SYSDATE) BETWEEN TRUNC(NVL(csad.start_date_active, SYSDATE))
6020 and TRUNC(NVL(csad.end_date_active, SYSDATE))
6021 and csat.from_to_status_code IS NOT NULL
6022 and csat.relationship_type_id IS NULL
6023 and csat.incident_status_id IS NOT NULL
6024 and csad.action_code NOT like 'NOTIFY%'
6025 and csad.relationship_type_id IN
6026 ( select cil.link_type_id
6027 FROM cs_incident_links cil
6028 WHERE cil.subject_id = l_request_id)
6029 AND TO_CHAR(csad.event_condition_id) || csad.action_code >
6030 TO_CHAR(l_event_condition_id) || l_action_code
6031 ORDER BY index_cols;
6032
6033 sel_action_rec sel_action_csr%ROWTYPE;
6034
6035 BEGIN
6036
6037 IF (funmode = 'RUN') THEN
6038
6039 l_update_conditions_list := WF_ENGINE.GetItemAttrText(
6040 itemtype => itemtype,
6041 itemkey => itemkey,
6042 aname => 'UPDATE_CONDITION_LIST' );
6043
6044 l_update_actions_list := WF_ENGINE.GetItemAttrText(
6045 itemtype => itemtype,
6046 itemkey => itemkey,
6047 aname => 'UPDATE_ACTION_LIST' );
6048
6049 IF (l_update_conditions_list IS NOT NULL AND l_update_actions_list IS NOT NULL) THEN
6050 result := 'COMPLETE:N';
6051 ELSE
6052
6053 l_overflow_flag := WF_ENGINE.GetItemAttrText(
6054 itemtype => itemtype,
6055 itemkey => itemkey,
6056 aname => 'MORE_UPDATE_ACTION_LIST');
6057
6058 IF (l_overflow_flag = 'Y') THEN
6059
6060 -- Reset the Overflow flag
6061 WF_ENGINE.SetItemAttrText(
6062 itemtype => itemtype,
6063 itemkey => itemkey,
6064 aname => 'MORE_UPDATE_ACTION_LIST',
6065 avalue => '' );
6066
6067 l_event_condition_id := WF_ENGINE.GetItemAttrNumber(
6068 itemtype => itemtype,
6069 itemkey => itemkey,
6070 aname => 'UPDATE_EVENT_CONDITION_ID');
6071 l_action_code := WF_ENGINE.GetItemAttrText(
6072 itemtype => itemtype,
6073 itemkey => itemkey,
6074 aname => 'UPDATE_ACTION_CODE');
6075 l_event_name := WF_ENGINE.GetItemAttrText(
6076 itemtype => itemtype,
6077 itemkey => itemkey,
6078 aname => 'EVENTNAME' );
6079 l_request_number := WF_ENGINE.GetItemAttrText(
6080 itemtype => itemtype,
6081 itemkey => itemkey,
6082 aname => 'REQUEST_NUMBER' );
6083 l_request_id := WF_ENGINE.GetItemAttrNumber(
6084 itemtype => itemtype,
6085 itemkey => itemkey,
6086 aname => 'REQUEST_ID' );
6087
6088 OPEN sel_action_csr;
6089 LOOP
6090 FETCH sel_action_csr INTO sel_action_rec;
6091 EXIT WHEN sel_action_csr%NOTFOUND;
6092 l_char_event_condition_id := TO_CHAR(sel_action_rec.event_condition_id);
6093
6094 IF (nvl(LENGTH(l_update_conditions_list),0) +
6095 nvl(LENGTH(l_char_event_condition_id),0) + 1) <= 4000 OR
6096 (nvl(LENGTH(l_update_actions_list),0) +
6097 nvl(LENGTH(sel_action_rec.action_code),0) + 1 ) <= 4000 THEN
6098
6099 IF l_update_conditions_list IS NULL THEN
6100 l_update_conditions_list := l_char_event_condition_id;
6101 l_update_actions_list := sel_action_rec.action_code;
6102 ELSE
6103 l_update_conditions_list := l_update_conditions_list || ' ' || l_char_event_condition_id;
6104 l_update_actions_list := l_update_actions_list || ' ' || sel_action_rec.action_code;
6105 END IF;
6106 ELSE
6107
6108 WF_ENGINE.SetItemAttrText(
6109 itemtype => itemtype,
6110 itemkey => itemkey,
6111 aname => 'MORE_UPDATE_ACTION_LIST',
6112 avalue => 'Y' );
6113 EXIT;
6114
6115 END IF;
6116 END LOOP;
6117 CLOSE sel_action_csr;
6118
6119 IF (l_update_conditions_list IS NOT NULL AND l_update_actions_list IS NOT NULL) THEN
6120
6121 WF_ENGINE.SetItemAttrText(
6122 itemtype => itemtype,
6123 itemkey => itemkey,
6124 aname => 'UPDATE_CONDITION_LIST',
6125 avalue => l_update_conditions_list );
6126 WF_ENGINE.SetItemAttrText(
6127 itemtype => itemtype,
6128 itemkey => itemkey,
6129 aname => 'UPDATE_ACTION_LIST',
6130 avalue => l_update_actions_list );
6131
6132 result := 'COMPLETE:N';
6133 ELSE
6134 result := 'COMPLETE:Y';
6135 END IF;
6136
6137 ELSE /** IF (l_overflow_flag = 'Y') **/
6138
6139 result := 'COMPLETE:Y';
6140
6141 END IF;
6142
6143 END IF;
6144
6145
6146 ELSIF (funmode = 'CANCEL') THEN
6147 result := 'COMPLETE';
6148 END IF;
6149
6150 EXCEPTION
6151 WHEN OTHERS THEN
6152 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Verify_Update_Rules_Done',
6153 itemtype, itemkey, actid, funmode);
6154 RAISE;
6155
6156 END Verify_Update_Rules_Done;
6157
6158
6159 /***********************************************************************
6160 -- Get_Request_Attributes
6161 -- This procedure initializes the item attributes that will remain constant
6162 -- over the duration of the Workflow. These attributes include REQUEST_ID,
6163 -- REQUEST_NUMBER, REQUEST_DATE, and REQUEST_TYPE.
6164 -- Modification History:
6165 --
6166 -- Date Name Desc
6167 -- -------- ---------- --------------------------------------
6168 -- 06/23/2004 RMANABAT Fix for bug 3715297. set SENDER_ROLE
6169 -- attribute when event is NOT raised from BES wrapper
6170 -- api, like in Solutions Linked event owned by KM.
6171 -- 06/08/2006 klou Fix bug 5245018. Added call to pass the attribute value
6172 -- for problem code
6173 ***********************************************************************/
6174
6175 PROCEDURE Get_Request_Attributes( itemtype VARCHAR2,
6176 itemkey VARCHAR2,
6177 actid NUMBER,
6178 funmode VARCHAR2,
6179 result OUT NOCOPY VARCHAR2 ) IS
6180
6181 l_return_status VARCHAR2(1);
6182 l_msg_count NUMBER;
6183 l_msg_data VARCHAR2(2000);
6184 l_owner_role VARCHAR2(100);
6185 l_owner_name VARCHAR2(240);
6186 l_errmsg_name VARCHAR2(30);
6187 l_old_incident_owner_id NUMBER;
6188 l_new_contact_point_id NUMBER;
6189 l_new_contact_point_name VARCHAR2(360);
6190 l_API_ERROR EXCEPTION;
6191
6192 l_request_number VARCHAR2(64);
6193
6194 l_resource_id NUMBER;
6195 l_role_display_name VARCHAR2(360);
6196 l_role_name VARCHAR2(320);
6197
6198 /******************
6199 CURSOR l_ServiceRequest_csr IS
6200 SELECT *
6201 FROM CS_INCIDENTS_WORKFLOW_V
6202 WHERE INCIDENT_NUMBER = l_request_number;
6203 ***************/
6204
6205 /**
6206 Going directly to TL tables to solve performance issue of
6207 non-mergeable views and excessive shared memory usage.
6208 rmanabat 03/18/03. Bug 2857365 .
6209 **/
6210
6211 /* 03/01/2004 - RHUNGUND - Bug fix for 3432700
6212
6213 Performance fine-tuning.
6214 Removed outer joins from the following where conditions
6215 1) AND INC.INCIDENT_TYPE_ID = TYPE.INCIDENT_TYPE_ID(+)
6216 2) AND TYPE.LANGUAGE(+) = userenv('LANG')
6217 3) AND INC.INCIDENT_URGENCY_ID = URGENCY.INCIDENT_URGENCY_ID(+)
6218 4) AND INC.INCIDENT_SEVERITY_ID = SEVERITY.INCIDENT_SEVERITY_ID(+)
6219 */
6220
6221 /* 03/31/2004 - RHUNGUND - Bug fix for 3531540
6222 Re-introduce the following outer join :
6223 AND INC.INCIDENT_URGENCY_ID = URGENCY.INCIDENT_URGENCY_ID(+)
6224 since URGENCY is not a mandatory sr attribute and if a sr does not have an URGENCY value, the following SQL will not bring up any records if outer join is not present
6225 */
6226
6227 CURSOR l_ServiceRequest_csr IS
6228 SELECT INC.INCIDENT_ID,
6229 INC.SUMMARY,
6230 INC.INCIDENT_OWNER_ID,
6231 INC.INVENTORY_ITEM_ID,
6232 INC.EXPECTED_RESOLUTION_DATE,
6233 INC.INCIDENT_DATE,
6234 INC.CUSTOMER_PRODUCT_ID,
6235 TYPE.NAME INCIDENT_TYPE,
6236 SEVERITY.NAME SEVERITY,
6237 STATUS.NAME STATUS_CODE,
6238 URGENCY.NAME URGENCY,
6239 RA2.PARTY_NAME CUSTOMER_NAME,
6240 CSLKUP.DESCRIPTION PROBLEM_CODE_DESCRIPTION,
6241 MTL.DESCRIPTION PRODUCT_DESCRIPTION,
6242 INC.PROBLEM_CODE --5245018
6243 FROM CS_INCIDENTS_ALL_VL INC,
6244 --CS_INCIDENT_TYPES_VL TYPE,
6245 CS_INCIDENT_TYPES_TL TYPE,
6246 --CS_INCIDENT_SEVERITIES_VL SEVERITY,
6247 CS_INCIDENT_SEVERITIES_TL SEVERITY,
6248 CS_INCIDENT_STATUSES_VL STATUS,
6249 --CS_INCIDENT_URGENCIES_VL URGENCY,
6250 CS_INCIDENT_URGENCIES_TL URGENCY,
6251 HZ_PARTIES RA2,
6252 CS_LOOKUPS CSLKUP,
6253 --MTL_SYSTEM_ITEMS_VL MTL
6254 MTL_SYSTEM_ITEMS_TL MTL
6255 WHERE INC.INCIDENT_NUMBER = l_request_number
6256 AND INC.INCIDENT_TYPE_ID = TYPE.INCIDENT_TYPE_ID
6257 AND TYPE.LANGUAGE = userenv('LANG')
6258 AND INC.INCIDENT_STATUS_ID = STATUS.INCIDENT_STATUS_ID
6259 AND INC.INCIDENT_URGENCY_ID = URGENCY.INCIDENT_URGENCY_ID(+)
6260 AND URGENCY.LANGUAGE(+) = userenv('LANG')
6261 AND INC.CUSTOMER_ID = RA2.PARTY_ID(+)
6262 AND INC.INCIDENT_SEVERITY_ID = SEVERITY.INCIDENT_SEVERITY_ID
6263 AND SEVERITY.LANGUAGE(+) = userenv('LANG')
6264 AND INC.PROBLEM_CODE = CSLKUP.LOOKUP_CODE(+)
6265 AND CSLKUP.LOOKUP_TYPE(+) = 'REQUEST_PROBLEM_CODE'
6266 AND MTL.INVENTORY_ITEM_ID(+) = INC.INVENTORY_ITEM_ID
6267 AND MTL.LANGUAGE(+) = userenv('LANG')
6268 AND (MTL.ORGANIZATION_ID = CS_STD.Get_Item_Valdn_Orgzn_ID OR MTL.ORGANIZATION_ID IS NULL);
6269 --AND NVL(MTL.ORGANIZATION_ID,CS_STD.Get_Item_Valdn_Orgzn_ID) = CS_STD.Get_Item_Valdn_Orgzn_ID;
6270
6271 l_ServiceRequest_rec l_ServiceRequest_csr%ROWTYPE;
6272
6273
6274 /***
6275 New 03/17/03. rmanabat
6276 Fix for bug 2837253.
6277 ***/
6278
6279 l_incident_owner_id NUMBER;
6280 --l_source_id NUMBER;
6281
6282 /***
6283 CURSOR l_get_source_id IS
6284 SELECT emp.source_id
6285 FROM jtf_rs_resource_extns emp
6286 WHERE emp.resource_id = l_incident_owner_id;
6287 ***/
6288
6289 /*** end New 03/17/03. rmanabat ***/
6290
6291 CURSOR l_get_source_id(p_resource_id IN NUMBER) IS
6292 select emp.source_id , emp.resource_name
6293 from jtf_rs_resource_extns_vl emp
6294 where emp.resource_id = p_resource_id;
6295 l_get_source_id_rec l_get_source_id%ROWTYPE;
6296
6297 CURSOR l_sel_adhocrole_csr(c_role_name IN VARCHAR2) IS
6298 SELECT display_name,expiration_date
6299 FROM wf_local_roles
6300 WHERE name = c_role_name;
6301 l_sel_adhocrole_rec l_sel_adhocrole_csr%ROWTYPE;
6302
6303 BEGIN
6304
6305 IF (funmode = 'RUN') THEN
6306
6307 l_request_number := WF_ENGINE.GetItemAttrText(
6308 itemtype => itemtype,
6309 itemkey => itemkey,
6310 aname => 'REQUEST_NUMBER' );
6311
6312 OPEN l_ServiceRequest_csr;
6313 FETCH l_ServiceRequest_csr INTO l_ServiceRequest_rec;
6314 CLOSE l_ServiceRequest_csr;
6315
6316 IF (l_ServiceRequest_rec.incident_owner_id IS NOT NULL) THEN
6317
6318 l_incident_owner_id := l_ServiceRequest_rec.incident_owner_id;
6319 OPEN l_get_source_id(l_incident_owner_id);
6320 FETCH l_get_source_id INTO l_get_source_id_rec;
6321
6322 IF (l_get_source_id%FOUND AND l_get_source_id_rec.source_id IS NOT NULL) THEN
6323
6324 -- Retrieve the role name for the request owner
6325 CS_WORKFLOW_PUB.Get_Employee_Role (
6326 p_api_version => 1.0,
6327 p_return_status => l_return_status,
6328 p_msg_count => l_msg_count,
6329 p_msg_data => l_msg_data,
6330 --p_employee_id => l_ServiceRequest_rec.incident_owner_id,
6331 p_employee_id => l_get_source_id_rec.source_id,
6332 p_role_name => l_owner_role,
6333 p_role_display_name => l_owner_name );
6334
6335 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) OR
6336 (l_owner_role is NULL) THEN
6337 CLOSE l_get_source_id;
6338 wf_core.context( pkg_name => 'CS_WORKFLOW_PUB',
6339 proc_name => 'Get_Employee_Role',
6340 arg1 => 'p_employee_id=>'||l_get_source_id_rec.source_id);
6341 l_errmsg_name := 'CS_WF_SR_CANT_FIND_OWNER';
6342
6343 raise l_API_ERROR;
6344 END IF;
6345
6346 ELSE
6347 CLOSE l_get_source_id;
6348 wf_core.context( pkg_name => 'CS_WF_AUTO_NTFY_UPDATE_PKG',
6349 proc_name => 'Get_Request_Attributes',
6350 arg1 => 'p_employee_id=>'|| l_get_source_id_rec.source_id);
6351 l_errmsg_name := 'CS_WF_SR_CANT_FIND_OWNER';
6352 raise l_API_ERROR;
6353
6354 END IF;
6355
6356 IF l_get_source_id%ISOPEN THEN
6357 CLOSE l_get_source_id;
6358 END IF;
6359
6360
6361 END IF;
6362
6363
6364
6365 /*******
6366 Note: Ideally, these attributes should be set before the event is raised, in
6367 the BES wrapper API. Take the scenario when an SR is created and an event is
6368 raised, the event is placed in the WF_DEFERRED queue. If the SR is updated
6369 before the event is de-queued, these attributes would reflect the latest data,
6370 including those which were changed, and not those when the SR was created.
6371 The disadvantage of adding this as part of the parameter list is the per-
6372 formance cost. The more parameters are added when raising the event, the
6373 more theperformance deteriorates (as pointed out by the Workflow team. max.
6374 number of parameters in an event is 100).
6375 *******/
6376
6377 -- Initialize item attributes that will remain constant
6378 WF_ENGINE.SetItemAttrDate(
6379 itemtype => 'SERVEREQ',
6380 itemkey => itemkey,
6381 aname => 'REQUEST_DATE',
6382 avalue => l_ServiceRequest_rec.incident_date );
6383
6384 WF_ENGINE.SetItemAttrNumber(
6385 itemtype => 'SERVEREQ',
6386 itemkey => itemkey,
6387 aname => 'REQUEST_ID',
6388 avalue => l_ServiceRequest_rec.incident_id );
6389
6390 /***** IF Request_id is given, request_number is derived in Check_Rules_For_Event()
6391 WF_ENGINE.SetItemAttrText(
6392 itemtype => 'SERVEREQ',
6393 itemkey => itemkey,
6394 aname => 'REQUEST_NUMBER',
6395 avalue => l_ServiceRequest_rec.incident_number );
6396 *****/
6397
6398 WF_ENGINE.SetItemAttrText(
6399 itemtype => 'SERVEREQ',
6400 itemkey => itemkey,
6401 aname => 'REQUEST_TYPE',
6402 avalue => l_ServiceRequest_rec.incident_type );
6403
6404
6405 -- Update service request item attributes
6406 WF_ENGINE.SetItemAttrNumber(
6407 itemtype => 'SERVEREQ',
6408 itemkey => itemkey,
6409 aname => 'OWNER_ID',
6410 avalue => l_ServiceRequest_rec.incident_owner_id );
6411
6412 WF_ENGINE.SetItemAttrText(
6413 itemtype => 'SERVEREQ',
6414 itemkey => itemkey,
6415 aname => 'OWNER_ROLE',
6416 avalue => l_owner_role );
6417
6418 WF_ENGINE.SetItemAttrText(
6419 itemtype => 'SERVEREQ',
6420 itemkey => itemkey,
6421 aname => 'OWNER_NAME',
6422 avalue => l_owner_name );
6423
6424 WF_ENGINE.SetItemAttrNumber(
6425 itemtype => 'SERVEREQ',
6426 itemkey => itemkey,
6427 aname => 'CUSTOMER_PRODUCT_ID',
6428 avalue => l_ServiceRequest_rec.customer_product_id );
6429
6430 WF_ENGINE.SetItemAttrDate(
6431 itemtype => 'SERVEREQ',
6432 itemkey => itemkey,
6433 aname => 'EXPECTED_RESOLUTION_DATE',
6434 avalue => l_ServiceRequest_rec.expected_resolution_date );
6435
6436 WF_ENGINE.SetItemAttrNumber(
6437 itemtype => 'SERVEREQ',
6438 itemkey => itemkey,
6439 aname => 'INVENTORY_ITEM_ID',
6440 avalue => l_ServiceRequest_rec.inventory_item_id );
6441
6442 WF_ENGINE.SetItemAttrText(
6443 itemtype => 'SERVEREQ',
6444 itemkey => itemkey,
6445 aname => 'PROBLEM_DESCRIPTION',
6446 avalue => l_ServiceRequest_rec.problem_code_description );
6447
6448 -- 5245018_start
6449 WF_ENGINE.SetItemAttrText(
6450 itemtype => 'SERVEREQ',
6451 itemkey => itemkey,
6452 aname => 'PROBLEM_CODE',
6453 avalue => l_ServiceRequest_rec.problem_code );
6454 -- 5245018_eof
6455
6456 WF_ENGINE.SetItemAttrText(
6457 itemtype => 'SERVEREQ',
6458 itemkey => itemkey,
6459 aname => 'PRODUCT_DESCRIPTION',
6460 avalue => l_ServiceRequest_rec.product_description );
6461
6462 WF_ENGINE.SetItemAttrText(
6463 itemtype => 'SERVEREQ',
6464 itemkey => itemkey,
6465 aname => 'REQUEST_CUSTOMER',
6466 avalue => l_ServiceRequest_rec.customer_name );
6467
6468 WF_ENGINE.SetItemAttrText(
6469 itemtype => 'SERVEREQ',
6470 itemkey => itemkey,
6471 aname => 'REQUEST_SEVERITY',
6472 avalue => l_ServiceRequest_rec.severity );
6473
6474 WF_ENGINE.SetItemAttrText(
6475 itemtype => 'SERVEREQ',
6476 itemkey => itemkey,
6477 aname => 'REQUEST_STATUS',
6478 avalue => l_ServiceRequest_rec.status_code );
6479
6480 WF_ENGINE.SetItemAttrText(
6481 itemtype => 'SERVEREQ',
6482 itemkey => itemkey,
6483 aname => 'REQUEST_SUMMARY',
6484 avalue => l_ServiceRequest_rec.summary );
6485
6486 WF_ENGINE.SetItemAttrText(
6487 itemtype => 'SERVEREQ',
6488 itemkey => itemkey,
6489 aname => 'REQUEST_URGENCY',
6490 avalue => l_ServiceRequest_rec.urgency );
6491
6492
6493 -- Get the old incident_owner role if old incident owner is given
6494 l_old_incident_owner_id := WF_ENGINE.GetItemAttrText(
6495 itemtype => itemtype,
6496 itemkey => itemkey,
6497 aname => 'PREV_OWNER_ID');
6498
6499 IF (l_old_incident_owner_id IS NOT NULL) THEN
6500
6501 CS_WORKFLOW_PUB.Get_Employee_Role (
6502 p_api_version => 1.0,
6503 p_return_status => l_return_status,
6504 p_msg_count => l_msg_count,
6505 p_msg_data => l_msg_data,
6506 p_employee_id => l_old_incident_owner_id,
6507 p_role_name => l_owner_role,
6508 p_role_display_name => l_owner_name );
6509
6510 IF (l_owner_role IS NOT NULL) THEN
6511 WF_ENGINE.SetItemAttrText(
6512 itemtype => itemtype,
6513 itemkey => itemkey,
6514 aname => 'PREV_OWNER_ROLE',
6515 avalue => l_owner_role );
6516 WF_ENGINE.SetItemAttrText(
6517 itemtype => itemtype,
6518 itemkey => itemkey,
6519 aname => 'PREV_OWNER_NAME',
6520 avalue => l_owner_name );
6521 END IF;
6522
6523
6524 END IF;
6525
6526
6527 l_role_name := WF_ENGINE.GetItemAttrText(
6528 itemtype => itemtype,
6529 itemkey => itemkey,
6530 aname => 'SENDER_ROLE' );
6531
6532 IF (l_role_name IS NULL) THEN
6533
6534 l_resource_id := NVL(FND_PROFILE.VALUE('CS_SR_DEFAULT_SYSTEM_RESOURCE'), -1);
6535 OPEN l_get_source_id(l_resource_id);
6536 FETCH l_get_source_id INTO l_get_source_id_rec;
6537
6538 l_role_name := 'CS_WF_ROLE_DUMMY';
6539 OPEN l_sel_adhocrole_csr(l_role_name);
6540 FETCH l_sel_adhocrole_csr INTO l_sel_adhocrole_rec;
6541
6542 IF (l_sel_adhocrole_csr%FOUND) THEN
6543
6544 -- expired adhoc role, renew expiration date.
6545 IF (nvl(l_sel_adhocrole_rec.EXPIRATION_DATE, SYSDATE) < sysdate) THEN
6546 wf_directory.SetAdHocRoleExpiration(role_name => l_role_name,
6547 expiration_date => sysdate + 365);
6548 END IF;
6549
6550 -- change display name if needed.
6551 IF (l_sel_adhocrole_rec.display_name <> l_get_source_id_rec.resource_name) THEN
6552 l_role_display_name := l_get_source_id_rec.resource_name;
6553 wf_directory.SetAdHocRoleAttr(role_name => l_role_name,
6554 display_name => l_role_display_name);
6555 END IF;
6556
6557 ELSE
6558
6559 wf_directory.CreateAdHocRole(role_name => l_role_name,
6560 role_display_name => l_role_display_name,
6561 expiration_date => sysdate + 365);
6562
6563 l_role_display_name := l_get_source_id_rec.resource_name;
6564
6565 wf_directory.SetAdHocRoleAttr(role_name => l_role_name,
6566 display_name => l_role_display_name);
6567 END IF;
6568
6569 IF l_sel_adhocrole_csr%ISOPEN THEN
6570 CLOSE l_sel_adhocrole_csr;
6571 END IF;
6572 IF l_get_source_id%ISOPEN THEN
6573 CLOSE l_get_source_id;
6574 END IF;
6575
6576 WF_ENGINE.SetItemAttrText(
6577 itemtype => 'SERVEREQ',
6578 itemkey => itemkey,
6579 aname => 'SENDER_ROLE',
6580 avalue => l_role_name );
6581
6582
6583 END IF; -- IF (l_role_name IS NULL)
6584
6585 result := 'COMPLETE';
6586
6587 ELSIF (funmode = 'CANCEL') THEN
6588 result := 'COMPLETE';
6589 END IF;
6590
6591 EXCEPTION
6592 WHEN l_API_ERROR THEN
6593 IF (l_ServiceRequest_csr%ISOPEN) THEN
6594 CLOSE l_ServiceRequest_csr;
6595 END IF;
6596 WF_CORE.Raise(l_errmsg_name);
6597 WHEN OTHERS THEN
6598 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Get_Request_Attributes',
6599 itemtype, itemkey, actid, funmode);
6600 RAISE;
6601
6602 END Get_Request_Attributes;
6603
6604
6605 /**************************************************************
6606 -- pull_from_list
6607 -- Pull an element from the list , and return the element
6608 -- and the updated list
6609 **************************************************************/
6610
6611 PROCEDURE pull_from_list(itemlist IN OUT NOCOPY VARCHAR2,
6612 element OUT NOCOPY VARCHAR2) IS
6613
6614 --l_out_list VARCHAR2(4000);
6615 l_space_pos NUMBER;
6616
6617 BEGIN
6618
6619 l_space_pos := instr(itemlist, ' ');
6620
6621 IF l_space_pos <> 0 THEN
6622 element := substr(itemlist, 1, l_space_pos - 1);
6623 itemlist := substr(itemlist, l_space_pos + 1, nvl(length(itemlist),0) - l_space_pos);
6624 ELSE -- No space, means only one record in list
6625 element := itemlist;
6626 itemlist := NULL;
6627 END IF;
6628
6629 END pull_from_list;
6630
6631
6632 -- ---------------------------------------------------------------------------
6633 -- Procedure : Get_Fnd_User_Role
6634 -- ---------------------------------------------------------------------------
6635
6636 PROCEDURE Get_Fnd_User_Role
6637 ( p_fnd_user_id IN NUMBER,
6638 x_role_name OUT NOCOPY VARCHAR2,
6639 x_role_display_name OUT NOCOPY VARCHAR2 ) IS
6640
6641 l_employee_id NUMBER;
6642
6643 BEGIN
6644 -- map the FND user to employee ID
6645 SELECT employee_id INTO l_employee_id
6646 FROM fnd_user
6647 WHERE user_id = p_fnd_user_id;
6648
6649 IF (l_employee_id IS NOT NULL) THEN
6650 wf_directory.getrolename
6651 ( p_orig_system => 'PER',
6652 p_orig_system_id => l_employee_id,
6653 p_name => x_role_name,
6654 p_display_name => x_role_display_name );
6655 ELSE
6656 wf_directory.getrolename
6657 ( p_orig_system => 'FND_USR',
6658 p_orig_system_id => p_fnd_user_id,
6659 p_name => x_role_name,
6660 p_display_name => x_role_display_name );
6661 END IF;
6662 END Get_Fnd_User_Role;
6663
6664
6665
6666 /***********************************************************************
6667 -- Create_Interaction_Activity
6668 --
6669 -- Modification History:
6670 -- Date Name Desc
6671 -- -------- ---------- --------------------------------------
6672 -- 07/14/2004 RMANABAT Fix for bug 3766921. Removed literals used in
6673 -- cursors.
6674 ***********************************************************************/
6675 PROCEDURE Create_Interaction_Activity(
6676 p_api_revision IN NUMBER,
6677 p_init_msg_list IN VARCHAR2,
6678 p_commit IN VARCHAR2,
6679 p_incident_id IN NUMBER,
6680 p_incident_number IN VARCHAR2 DEFAULT NULL,
6681 p_party_id IN NUMBER,
6682 p_user_id IN NUMBER,
6683 p_resp_appl_id IN NUMBER,
6684 p_resp_id IN NUMBER,
6685 p_login_id IN NUMBER,
6686 x_return_status OUT NOCOPY VARCHAR2,
6687 x_resource_id OUT NOCOPY NUMBER,
6688 x_resource_type OUT NOCOPY VARCHAR2,
6689 x_msg_count OUT NOCOPY NUMBER,
6690 x_msg_data OUT NOCOPY VARCHAR2) IS
6691
6692
6693 c_wrap_id NUMBER;
6694 l_int_wrapup_id NUMBER;
6695 l_act_wrapup_id NUMBER;
6696 --l_return_status VARCHAR2(1);
6697 --l_msg_count NUMBER;
6698 --l_msg_data VARCHAR2(2000);
6699 l_action_id NUMBER;
6700 l_action_item_id NUMBER;
6701 l_user_id NUMBER;
6702
6703 p_wrap_id NUMBER;
6704 l_new_interaction_id NUMBER;
6705 l_interaction_rec JTF_IH_PUB.interaction_rec_type;
6706 l_activity_rec JTF_IH_PUB.activity_rec_type;
6707
6708 l_default_int_outcome_id NUMBER;
6709 l_default_int_outcome jtf_ih_wrap_ups_vl.outcome_short_desc%TYPE;
6710 l_result_reqd jtf_ih_wrap_ups_vl.result_required%TYPE;
6711 l_default_int_result_id NUMBER;
6712 l_default_int_result jtf_ih_wrap_ups_vl.result_short_desc%TYPE;
6713 l_reason_reqd jtf_ih_wrap_ups_vl.reason_required%TYPE;
6714 l_default_int_reason_id jtf_ih_wrap_ups_vl.reason_id%TYPE;
6715 l_default_int_reason jtf_ih_wrap_ups_vl.reason_short_desc%TYPE;
6716 l_incident_number VARCHAR2(64);
6717 l_default_result_id NUMBER;
6718 l_default_reason_id NUMBER;
6719 l_default_result jtf_ih_wrap_ups_vl.result_short_desc%TYPE;
6720 l_activity_id NUMBER;
6721 l_default_reason jtf_ih_wrap_ups_vl.reason_short_desc%TYPE;
6722
6723 l_default_outcome_id NUMBER;
6724 l_default_outcome jtf_ih_wrap_ups_vl.outcome_short_desc%TYPE;
6725
6726 l_action_item VARCHAR2(80);
6727 l_action VARCHAR2(80);
6728
6729 l_NO_RESOURCE_FOUND EXCEPTION;
6730
6731 CURSOR is_interaction_active(c_incident_id number) IS
6732 select b.interaction_id
6733 from jtf_ih_activities a,
6734 jtf_ih_interactions b
6735 where a.doc_ref='SR'
6736 and a.doc_id = c_incident_id
6737 and a.interaction_id = b.interaction_id
6738 and b.active = 'Y';
6739
6740 CURSOR wrap_cur IS
6741 select outcome_id,
6742 outcome_short_desc,
6743 result_required,
6744 result_id,
6745 result_short_desc,
6746 reason_required,
6747 reason_id,
6748 reason_short_desc
6749 from jtf_ih_wrap_ups_vl
6750 where wrap_id = c_wrap_id;
6751
6752 CURSOR c_action_item_id IS
6753 SELECT nvl(action_item_id,0)
6754 FROM jtf_ih_action_items_vl
6755 --WHERE action_item = 'Sr'
6756 WHERE action_item = l_action_item
6757 AND rownum < 2;
6758
6759 CURSOR c_action_id IS
6760 SELECT nvl(action_id,0)
6761 FROM jtf_ih_actions_vl
6762 --WHERE action = 'Automated Email Sent'
6763 WHERE action = l_action
6764 AND rownum < 2;
6765
6766 CURSOR c_incident_number IS
6767 SELECT incident_number
6768 FROM cs_incidents_all_b
6769 WHERE incident_id = p_incident_id;
6770
6771
6772 CURSOR sel_contact_party_name_csr IS
6773 SELECT PARTY_NAME
6774 FROM HZ_PARTIES
6775 WHERE
6776 PARTY_ID = p_party_id;
6777
6778 l_int_profile varchar2(30);
6779 l_failed NUMBER := 0;
6780 l_msg_index_OUT NUMBER;
6781 l_error_text VARCHAR2(2000);
6782 NL VARCHAR2(1);
6783 d_user_id NUMBER;
6784 d_resp_appl_id NUMBER;
6785 d_resp_id NUMBER;
6786 d_login_id NUMBER;
6787
6788 BEGIN
6789
6790 x_return_status := FND_API.G_RET_STS_SUCCESS;
6791
6792 l_int_wrapup_id := FND_PROFILE.Value('CSC_CC_WRAPUP_INTERACTION_DEFAULTS');
6793
6794 l_action_item := 'Sr';
6795 l_action := 'Automated Email Sent';
6796
6797 l_interaction_rec := JTF_IH_PUB.INIT_INTERACTION_REC;
6798 l_activity_rec := JTF_IH_PUB.INIT_ACTIVITY_REC;
6799
6800 l_int_profile := FND_PROFILE.Value('CS_SR_INTERACTION_LOGGING');
6801 NL := fnd_global.Local_Chr(10);
6802
6803 IF ( l_int_profile is null or l_int_profile ='AUTO_INT_LOG' ) THEN
6804
6805
6806 IF (p_user_id is null) THEN
6807 fnd_profile.get('USER_ID', d_user_id);
6808 ELSE
6809 d_user_id := p_user_id;
6810 END IF;
6811
6812 IF (p_login_id is null) THEN
6813 fnd_profile.get('LOGIN_ID', d_login_id);
6814 ELSE
6815 d_login_id := p_login_id;
6816 END IF;
6817
6818 IF (p_resp_id is null) THEN
6819 fnd_profile.get('RESP_ID', d_resp_id);
6820 ELSE
6821 d_resp_id := p_resp_id;
6822 END IF;
6823
6824 IF (p_resp_appl_id is null) THEN
6825 fnd_profile.get('RESP_APPL_ID', d_resp_appl_id);
6826 ELSE
6827 d_resp_appl_id := p_resp_appl_id;
6828 END IF;
6829
6830
6831 IF ( l_int_wrapup_id is not null ) THEN
6832 c_wrap_id := l_int_wrapup_id;
6833
6834 OPEN wrap_cur;
6835 fetch wrap_cur into
6836 l_default_int_outcome_id,
6837 l_default_int_outcome,
6838 l_result_reqd,
6839 l_default_int_result_id,
6840 l_default_int_result,
6841 l_reason_reqd,
6842 l_default_int_reason_id,
6843 l_default_int_reason;
6844 close wrap_cur;
6845
6846 /* Roopa - Begin - Fix for bug 3360069 */
6847 /* Initializing the local vars with FND_GLOBAL values if the local vars are null in value */
6848 /* It's necessary to hard code the value of d_resp_appl_id to 170 since
6849 WF item attr RESP_APPL_ID has returned a null value and create and close
6850 interaction calls will fail if we pass a null value for resp_appl_id/handler_id */
6851 IF(d_resp_appl_id is NULL or d_resp_appl_id = -1) THEN
6852 d_resp_appl_id := 170;
6853 END IF;
6854
6855 IF(d_resp_id is NULL) THEN
6856 d_resp_id := FND_GLOBAL.RESP_ID;
6857 END IF;
6858
6859 IF(d_user_id is NULL) THEN
6860 d_user_id := FND_GLOBAL.USER_ID;
6861 END IF;
6862
6863 IF(d_login_id is NULL) THEN
6864 d_login_id := FND_GLOBAL.LOGIN_ID;
6865 END IF;
6866 /* Roopa - End - Fix for bug 3360069 */
6867
6868 l_interaction_rec.party_id := p_party_id;
6869 -- Get the application id AND pass that IN handler_id
6870 l_interaction_rec.handler_id := d_resp_appl_id;
6871 l_user_id := d_user_id;
6872
6873 -- Get the corresponding RESOURCE_ID, fOR the l_user_id, FROM JTF Resource schema
6874 /****
6875 SELECT a.resource_id
6876 into l_interaction_rec.resource_id
6877 FROM jtf_rs_resource_extns a
6878 WHERE a.user_id = l_user_id;
6879 ****/
6880
6881 -- Get the resource from the profile instead. Part of fix for bug 3360069.
6882 -- rmanabat 01/19/04.
6883 l_interaction_rec.resource_id := FND_PROFILE.VALUE('CS_SR_DEFAULT_SYSTEM_RESOURCE');
6884 IF (l_interaction_rec.resource_id is NULL) THEN
6885 raise l_NO_RESOURCE_FOUND;
6886 END IF;
6887
6888 l_interaction_rec.outcome_id := l_default_int_outcome_id;
6889 l_interaction_rec.result_id := l_default_int_result_id;
6890 l_interaction_rec.reason_id := l_default_int_reason_id;
6891 l_interaction_rec.start_date_time := sysdate;
6892 l_interaction_rec.duration := 0;
6893
6894
6895 -- Start the interaction
6896 jtf_ih_pub.open_interaction(
6897 1.0,
6898 p_init_msg_list,
6899 p_commit,
6900 d_resp_appl_id,
6901 d_resp_id,
6902 d_user_id,
6903 d_login_id,
6904 x_return_status,
6905 x_msg_count,
6906 x_msg_data,
6907 l_interaction_rec,
6908 l_new_interaction_id);
6909
6910
6911 END IF; -- IF ( l_int_wrapup_id is not null )
6912
6913
6914 IF (l_new_interaction_id IS NULL OR x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6915 RAISE FND_API.G_EXC_ERROR;
6916
6917 ELSE
6918
6919
6920 l_act_wrapup_id := FND_PROFILE.Value('CSC_CC_WRAPUP_ACTIVITY_DEFAULTS');
6921
6922 IF (l_act_wrapup_id is not null) THEN
6923 -- Get the Activity defaults
6924 p_wrap_id := l_act_wrapup_id;
6925
6926 OPEN wrap_cur;
6927 FETCH wrap_cur INTO
6928 l_default_outcome_id,
6929 l_default_outcome,
6930 l_result_reqd,
6931 l_default_result_id,
6932 l_default_result,
6933 l_reason_reqd,
6934 l_default_reason_id,
6935 l_default_reason;
6936 CLOSE wrap_cur;
6937
6938 OPEN c_action_item_id;
6939 FETCH c_action_item_id INTO
6940 l_action_item_id;
6941 CLOSE c_action_item_id;
6942
6943 OPEN c_action_id;
6944 FETCH c_action_id INTO l_action_id;
6945 CLOSE c_action_id;
6946
6947 IF (p_incident_number IS NULL) THEN
6948 OPEN c_incident_number;
6949 FETCH c_incident_number INTO l_incident_number;
6950 CLOSE c_incident_number;
6951 ELSE
6952 l_incident_number := p_incident_number;
6953 END IF;
6954
6955 l_activity_rec.interaction_id := l_new_interaction_id;
6956 l_activity_rec.action_id := l_action_id;
6957 l_activity_rec.outcome_id := l_default_outcome_id;
6958 l_activity_rec.result_id := l_default_result_id;
6959 l_activity_rec.reason_id := l_default_reason_id;
6960 l_activity_rec.action_item_id := l_action_item_id;
6961 --l_activity_rec.cust_account_id := l_account_id;
6962 l_activity_rec.doc_id := p_incident_id;
6963 l_activity_rec.doc_ref := 'SR';
6964 l_activity_rec.doc_source_object_name := l_incident_number;
6965 l_activity_rec.start_date_time := sysdate;
6966 --l_activity_rec.end_date_time := fnd_standard.system_date;
6967 l_activity_rec.end_date_time := sysdate;
6968
6969
6970 jtf_ih_pub.add_activity( 1.0,
6971 p_init_msg_list,
6972 p_commit,
6973 d_resp_appl_id,
6974 d_resp_id,
6975 d_user_id,
6976 d_login_id,
6977 x_return_status,
6978 x_msg_count,
6979 x_msg_data,
6980 l_activity_rec,
6981 l_activity_id);
6982
6983
6984 IF (l_activity_id IS NULL OR x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6985
6986 raise FND_API.G_EXC_ERROR;
6987 /**********
6988 l_failed = 1;
6989
6990 IF ( FND_MSG_PUB.Count_Msg > 0) THEN
6991 FOR i IN 1..FND_MSG_PUB.Count_Msg LOOP
6992 FND_MSG_PUB.Get(p_msg_index => i,
6993 p_encoded => 'F',
6994 p_data => l_msg_data,
6995 p_msg_index_OUT => l_msg_index_OUT );
6996 l_error_text := l_error_text || l_msg_data ||NL;
6997 END LOOP;
6998 END IF;
6999 **********/
7000
7001 END IF;
7002
7003
7004 END IF; -- IF (l_act_wrapup_id is not null)
7005
7006 /* Roopa - Begin - Fix for bug 3360069 */
7007 /* Initializing the local vars with FND_GLOBAL values if the local vars are null in value */
7008 IF(d_resp_appl_id is NULL or d_resp_appl_id = -1) THEN
7009 d_resp_appl_id := 170;
7010 END IF;
7011
7012 IF(d_resp_id is NULL) THEN
7013 d_resp_id := FND_GLOBAL.RESP_ID;
7014 END IF;
7015
7016 IF(d_user_id is NULL) THEN
7017 d_user_id := FND_GLOBAL.USER_ID;
7018 END IF;
7019
7020 IF(d_login_id is NULL) THEN
7021 d_login_id := FND_GLOBAL.LOGIN_ID;
7022 END IF;
7023 /* Roopa - End - Fix for bug 3360069 */
7024
7025
7026 l_interaction_rec.handler_id := d_resp_appl_id;
7027 l_interaction_rec.interaction_id := l_new_interaction_id;
7028 l_interaction_rec.outcome_id := l_default_int_outcome_id;
7029 l_interaction_rec.result_id := l_default_result_id;
7030 l_interaction_rec.reason_id := l_default_reason_id;
7031 --l_interaction_rec.end_date_time := fnd_standard.system_date;
7032 l_interaction_rec.end_date_time := sysdate;
7033
7034 jtf_ih_pub.close_interaction
7035 ( 1.0,
7036 p_init_msg_list,
7037 p_commit,
7038 d_resp_appl_id,
7039 d_resp_id,
7040 d_user_id,
7041 d_login_id,
7042 x_return_status,
7043 x_msg_count,
7044 x_msg_data,
7045 l_interaction_rec);
7046
7047 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
7048 raise FND_API.G_EXC_ERROR;
7049 END IF;
7050
7051 END IF; -- (l_new_interaction_id IS NOT NULL)
7052
7053
7054
7055
7056 END IF; -- IF ( l_int_profile is null or l_int_profile ='AUTO_INT_LOG' )
7057
7058 EXCEPTION
7059
7060 WHEN l_NO_RESOURCE_FOUND THEN
7061 x_return_status := FND_API.G_RET_STS_ERROR;
7062 FND_MSG_PUB.initialize;
7063 FND_MESSAGE.Set_Name('CS', 'CS_SR_WF_NO_INT_RESOURCE');
7064 FND_MESSAGE.Set_Token('API_NAME', 'CS_WF_AUTO_NTFY_UPDATE_PKG.Create_Interaction_Activity');
7065 FND_MSG_PUB.ADD;
7066 FND_MSG_PUB.Count_And_Get
7067 ( p_count => x_msg_count,
7068 p_data => x_msg_data
7069 );
7070
7071 WHEN FND_API.G_EXC_ERROR THEN
7072 x_return_status := FND_API.G_RET_STS_ERROR;
7073 FND_MSG_PUB.Count_And_Get
7074 ( p_count => x_msg_count,
7075 p_data => x_msg_data
7076 );
7077
7078 WHEN OTHERS THEN
7079 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
7080 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
7081 FND_MSG_PUB.Add_Exc_Msg('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Create_Interaction_Activity');
7082 END IF;
7083 FND_MSG_PUB.Count_And_Get
7084 ( p_count => x_msg_count,
7085 p_data => x_msg_data
7086 );
7087
7088
7089 END Create_Interaction_Activity;
7090
7091
7092
7093 /***********************************************************************
7094 -- SetWorkflowAdhocUser
7095 -- This procedure creates/updates a dummy adhoc user . This adhoc user
7096 -- is assigned the email address from the IN parameter and it's
7097 -- expiration date is extended if it has expired. This adhoc user is mainly
7098 -- used for notificaion to contacts, for performance reasons.
7099 --
7100 -- Modification History:
7101 -- Date Name Desc
7102 -- -------- ---------- --------------------------------------
7103 -- 07/13/2004 RMANABAT Created.
7104 -- 07/28/2004 RMANABAT Changed referred table in cursor from WF_LOCAL_USERS
7105 -- to WF_LOCAL_ROLES since calling create_adhocuser()
7106 -- creates a row in WF_LOCAL_ROLES .
7107 ***********************************************************************/
7108
7109 PROCEDURE SetWorkflowAdhocUser(
7110 p_wf_username IN OUT NOCOPY VARCHAR2,
7111 p_email_address IN VARCHAR2,
7112 p_display_name IN VARCHAR2 DEFAULT NULL) IS
7113
7114 CURSOR sel_user_csr(c_user_name IN VARCHAR2) IS
7115 SELECT display_name,expiration_date
7116 FROM wf_local_roles
7117 WHERE name = c_user_name;
7118 l_sel_user_rec sel_user_csr%ROWTYPE;
7119
7120 l_wf_username VARCHAR2(320);
7121 l_user_display_name VARCHAR2(360);
7122
7123 BEGIN
7124
7125 l_wf_username := p_wf_username;
7126 l_user_display_name := p_display_name;
7127
7128 OPEN sel_user_csr(l_wf_username);
7129 FETCH sel_user_csr INTO l_sel_user_rec;
7130
7131 IF (sel_user_csr%FOUND) THEN
7132
7133 -- expired adhoc user, renew expiration date.
7134 IF (nvl(l_sel_user_rec.EXPIRATION_DATE, SYSDATE) < sysdate) THEN
7135 wf_directory.SetAdHocUserExpiration(user_name => l_wf_username,
7136 expiration_date => sysdate + 365);
7137 END IF;
7138
7139 wf_directory.SetAdHocUserAttr(user_name => l_wf_username,
7140 display_name => l_user_display_name,
7141 email_address => p_email_address);
7142
7143 ELSE
7144
7145 WF_DIRECTORY.CreateAdHocUser(name => l_wf_username,
7146 display_name => l_user_display_name,
7147 email_address => p_email_address);
7148 END IF;
7149
7150 p_wf_username := l_wf_username;
7151
7152 IF sel_user_csr%ISOPEN THEN
7153 CLOSE sel_user_csr;
7154 END IF;
7155
7156 END SetWorkflowAdhocUser;
7157
7158
7159 /***********************************************************************
7160 -- SetWorkflowAdhocRole
7161 -- This procedure creates/updates a dummy adhoc role . This adhoc role
7162 -- is assigned the user list from the IN parameter and it's
7163 -- expiration date is extended if it has expired. This adhoc role is mainly
7164 -- used for notificaion to contacts, for performance reasons.
7165 --
7166 -- Modification History:
7167 -- Date Name Desc
7168 -- -------- ---------- --------------------------------------
7169 -- 07/13/2004 RMANABAT Created.
7170 ***********************************************************************/
7171 PROCEDURE SetWorkflowAdhocRole(
7172 p_wf_rolename IN OUT NOCOPY VARCHAR2,
7173 p_user_list IN VARCHAR2) IS
7174
7175 CURSOR l_sel_adhocrole_csr(c_role_name IN VARCHAR2) IS
7176 SELECT display_name,expiration_date
7177 FROM wf_local_roles
7178 WHERE name = c_role_name;
7179 l_sel_adhocrole_rec l_sel_adhocrole_csr%ROWTYPE;
7180
7181 l_wf_rolename VARCHAR2(320);
7182 l_role_display_name VARCHAR2(360);
7183
7184 BEGIN
7185
7186 l_wf_rolename := p_wf_rolename;
7187
7188 OPEN l_sel_adhocrole_csr(l_wf_rolename);
7189 FETCH l_sel_adhocrole_csr INTO l_sel_adhocrole_rec;
7190
7191 IF (l_sel_adhocrole_csr%FOUND) THEN
7192
7193 -- expired adhoc role, renew expiration date.
7194 IF (nvl(l_sel_adhocrole_rec.EXPIRATION_DATE, SYSDATE) < sysdate) THEN
7195 wf_directory.SetAdHocRoleExpiration(role_name => l_wf_rolename,
7196 expiration_date => sysdate + 365);
7197 END IF;
7198
7199 wf_directory.RemoveUsersFromAdHocRole(role_name => l_wf_rolename);
7200
7201 wf_directory.AddUsersToAdHocRole(role_name => l_wf_rolename,
7202 role_users => p_user_list);
7203
7204 ELSE
7205
7206 wf_directory.CreateAdHocRole(role_name => l_wf_rolename,
7207 role_display_name => l_role_display_name,
7208 role_users => p_user_list);
7209
7210 END IF;
7211
7212 IF l_sel_adhocrole_csr%ISOPEN THEN
7213 CLOSE l_sel_adhocrole_csr;
7214 END IF;
7215
7216 END SetWorkflowAdhocRole;
7217
7218
7219 PROCEDURE Prepare_HTML_Notification
7220 ( itemtype IN VARCHAR2,
7221 itemkey IN VARCHAR2,
7222 actid IN NUMBER,
7223 funmode IN VARCHAR2,
7224 result OUT NOCOPY VARCHAR2 ) IS
7225
7226 l_request_id NUMBER;
7227 l_contact_id NUMBER;
7228 l_contact_email VARCHAR2(240);
7229 l_adhoc_user VARCHAR2(240);
7230 l_contact_type VARCHAR2(240);
7231 l_language VARCHAR2(240);
7232 l_notification_pref VARCHAR2(240);
7233 l_message_name VARCHAR2(240);
7234
7235 l_contact_id_list VARCHAR2(2000);
7236 l_contact_email_list VARCHAR2(2000);
7237 l_adhoc_user_list VARCHAR2(2000);
7238 l_contact_type_list VARCHAR2(2000);
7239 l_language_list VARCHAR2(2000);
7240 l_notification_pref_list VARCHAR2(2000);
7241
7242 l_element VARCHAR2(100);
7243 l_element1 VARCHAR2(100);
7244 l_element2 VARCHAR2(100);
7245 l_notification_template VARCHAR2(240);
7246 l_user_display_name VARCHAR2(240);
7247 l_notify_recipient VARCHAR2(240);
7248 l_return_status VARCHAR2(3);
7249 l_msg_count NUMBER;
7250 l_msg_data VARCHAr2(1000);
7251 l_adhoc_role VARCHAr2(240);
7252 l_message_id NUMBER;
7253 l_count NUMBER := 0;
7254 l_request_number NUMBER;
7255 l_sender VARCHAR2(240);
7256 l_from_status VARCHAR2(240);
7257 l_to_status VARCHAR2(240);
7258
7259
7260 BEGIN
7261
7262 -- Log debug messages
7263
7264 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7265 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION')) THEN
7266
7267 dbg_msg := ('In CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION Procedure');
7268 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7269 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7270 END IF;
7271
7272 dbg_msg := ('ItemType :'||ItemType);
7273 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7274 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7275 END IF;
7276
7277 dbg_msg := ('ItemKey :'||ItemKey);
7278 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7279 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7280 END IF;
7281
7282 END IF;
7283 END IF;
7284
7285
7286 -- Get necessary item attributes
7287
7288
7289 IF (funmode = 'RUN') THEN
7290
7291 l_request_id := WF_ENGINE.GetItemAttrText(
7292 itemtype => itemtype,
7293 itemkey => itemkey,
7294 aname => 'REQUEST_ID' );
7295
7296 l_request_number := WF_ENGINE.GetItemAttrText(
7297 itemtype => itemtype,
7298 itemkey => itemkey,
7299 aname => 'REQUEST_NUMBER' );
7300
7301 l_sender := WF_ENGINE.GetItemAttrText(
7302 itemtype => itemtype,
7303 itemkey => itemkey,
7304 aname => 'SENDER_ROLE' );
7305
7306 l_contact_id_list := WF_ENGINE.GetItemAttrText(
7307 itemtype => itemtype,
7308 itemkey => itemkey,
7309 aname => 'CONTACT_ID_LIST' );
7310
7311 l_contact_email_list := WF_ENGINE.GetItemAttrText(
7312 itemtype => itemtype,
7313 itemkey => itemkey,
7314 aname => 'CONTACT_EMAIL_LIST' );
7315
7316 l_adhoc_user_list := WF_ENGINE.GetItemAttrText(
7317 itemtype => itemtype,
7318 itemkey => itemkey,
7319 aname => 'ADHOC_USER_LIST');
7320
7321 l_contact_type_list := WF_ENGINE.GetItemAttrText(
7322 itemtype => itemtype,
7323 itemkey => itemkey,
7324 aname => 'CONTACT_TYPE_LIST');
7325
7326 l_language_list := WF_ENGINE.GetItemAttrText(
7327 itemtype => itemtype,
7328 itemkey => itemkey,
7329 aname => 'LANGUAGE_LIST');
7330
7331 l_notification_pref_list := WF_ENGINE.GetItemAttrText(
7332 itemtype => itemtype,
7333 itemkey => itemkey,
7334 aname => 'NOTIFICATION_PREFERENCE_LIST');
7335
7336 l_message_name := WF_ENGINE.GetItemAttrText(
7337 itemtype => itemtype,
7338 itemkey => itemkey,
7339 aname => 'NTFY_MESSAGE_NAME');
7340
7341
7342 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7343 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION')) THEN
7344
7345 dbg_msg := ('l_request_id : '||l_request_id);
7346 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7347 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7348 END IF;
7349
7350 dbg_msg := ('l_request_number : '||l_request_number);
7351 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7352 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7353 END IF;
7354
7355 dbg_msg := ('l_sender : '||l_sender);
7356 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7357 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7358 END IF;
7359
7360 dbg_msg := ('l_contact_id_list : ' ||l_contact_id_list);
7361 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7362 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7363 END IF;
7364
7365 dbg_msg := ('l_contact_email_list : '||l_contact_email_list);
7366 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7367 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7368 END IF;
7369
7370 dbg_msg := ('l_adhoc_user_list : '||l_adhoc_user_list);
7371 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7372 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7373 END IF;
7374
7375 dbg_msg := ('l_contact_type_list : '||l_contact_type_list);
7376 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7377 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7378 END IF;
7379
7380 dbg_msg := ('l_language_list : '||l_language_list);
7381 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7382 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7383 END IF;
7384
7385 dbg_msg := ('l_notification_pref_list : '||l_notification_pref_list);
7386 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7387 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7388 END IF;
7389
7390 dbg_msg := ('l_message_name : '||l_message_name);
7391 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7392 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7393 END IF;
7394
7395 END IF;
7396 END IF;
7397
7398 IF l_message_name = 'CS_SR_IBU_EVT_STATUS_CHANGED' THEN
7399
7400 l_from_status := WF_ENGINE.GetItemAttrText(
7401 itemtype => itemtype,
7402 itemkey => itemkey,
7403 aname => 'REQUEST_STATUS_OLD');
7404
7405 l_to_status := WF_ENGINE.GetItemAttrText(
7406 itemtype => itemtype,
7407 itemkey => itemkey,
7408 aname => 'REQUEST_STATUS');
7409 END IF;
7410
7411 -- Get the message Name
7412 -- Set the Notification Details Required to send the email/wf html notification.
7413
7414 IF l_contact_id_list IS NOT NULL THEN
7415 l_count := 1;
7416
7417 pull_from_list(itemlist => l_contact_email_list,
7418 element => l_element);
7419
7420 pull_from_list(itemlist => l_contact_id_list,
7421 element => l_element1);
7422
7423 pull_from_list(itemlist => l_adhoc_user_list,
7424 element => l_adhoc_user);
7425
7426 pull_from_list(itemlist => l_contact_type_list,
7427 element => l_contact_type);
7428
7429 pull_from_list(itemlist => l_language_list,
7430 element => l_language);
7431
7432 pull_from_list(itemlist => l_notification_pref_list,
7433 element => l_notification_pref);
7434
7435 WF_ENGINE.SetItemAttrText
7436 ( itemtype => itemtype,
7437 itemkey => itemkey,
7438 AName => 'ADHOC_USER_LIST',
7439 AValue => l_adhoc_user_list);
7440
7441 WF_ENGINE.SetItemAttrText
7442 ( itemtype => itemtype,
7443 itemkey => itemkey,
7444 AName => 'CONTACT_ID_LIST',
7445 AValue => l_contact_id_list);
7446
7447 WF_ENGINE.SetItemAttrText
7448 ( itemtype => itemtype,
7449 itemkey => itemkey,
7450 AName => 'CONTACT_EMAIL_LIST',
7451 AValue => l_contact_email_list);
7452
7453 WF_ENGINE.SetItemAttrText
7454 ( itemtype => itemtype,
7455 itemkey => itemkey,
7456 AName => 'CONTACT_TYPE_LIST',
7457 AValue => l_contact_type_list);
7458
7459 WF_ENGINE.SetItemAttrText
7460 ( itemtype => itemtype,
7461 itemkey => itemkey,
7462 AName => 'NOTIFICATION_PREFERENCE_LIST',
7463 AValue => l_notification_pref_list);
7464
7465 WF_ENGINE.SetItemAttrText
7466 ( itemtype => itemtype,
7467 itemkey => itemkey,
7468 AName => 'LANGUAGE_LIST',
7469 AValue => l_language_list);
7470
7471 END IF;
7472
7473 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7474 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION')) THEN
7475
7476 dbg_msg := ('Processing HTML Notification following set of attributes');
7477 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7478 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7479 END IF;
7480
7481 dbg_msg := ('l_element : '||l_element);
7482 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7483 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7484 END IF;
7485
7486 dbg_msg := ('l_element1 : '||l_element1);
7487 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7488 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7489 END IF;
7490
7491 dbg_msg := ('l_adhoc_user : '||l_adhoc_user);
7492 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7493 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7494 END IF;
7495
7496 dbg_msg := ('l_contact_type : '||l_contact_type);
7497 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7498 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7499 END IF;
7500
7501 dbg_msg := ('l_language : '||l_language);
7502 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7503 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7504 END IF;
7505
7506 dbg_msg := ('l_notification_pref : '||l_notification_pref);
7507 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7508 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7509 END IF;
7510
7511 END IF;
7512 END IF;
7513
7514 -- Set the recipient role for the notification
7515
7516 WF_ENGINE.SetItemAttrText
7517 ( itemtype => itemtype,
7518 itemkey => itemkey,
7519 aname => 'NTFY_RECIPIENT',
7520 avalue => l_adhoc_user);
7521
7522
7523 l_contact_email := l_element;
7524 l_contact_id := to_number(l_element1);
7525
7526 -- Set the notification details as per the IBU templates.
7527
7528 -- Call IBU API wrapper
7529
7530 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7531 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION')) THEN
7532
7533 dbg_msg := ('Calling CS_WF_AUTO_NTFY_UPDATE_PKG.Set_HTML_Notification_Details Procedure');
7534 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7535 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7536 END IF;
7537
7538 END IF;
7539 END IF;
7540
7541 Set_HTML_Notification_Details
7542 ( p_itemtype => itemtype,
7543 p_itemkey => itemkey,
7544 p_actid => actid,
7545 p_funmode => funmode,
7546 p_contact_type => l_contact_type,
7547 p_contact_id => to_number(l_contact_id),
7548 p_request_id => to_number(l_request_id),
7549 p_request_number => l_request_number,
7550 p_sender => l_sender,
7551 p_email_preference => l_notification_pref,
7552 p_user_language => l_language,
7553 p_recipient => l_adhoc_user,
7554 p_message_name => l_message_name,
7555 p_from_status => l_from_status,
7556 p_to_status => l_to_status) ;
7557
7558
7559 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7560 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION')) THEN
7561
7562 dbg_msg := ('After Calling CS_WF_AUTO_NTFY_UPDATE_PKG.Set_HTML_Notification_Details Procedure');
7563 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7564 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7565 END IF;
7566
7567 END IF;
7568 END IF;
7569
7570 result := 'COMPLETE';
7571
7572 ELSIF (funmode = 'CANCEL') THEN
7573 result := 'COMPLETE';
7574 END IF;
7575
7576 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7577 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION')) THEN
7578
7579 dbg_msg := ('Prepare_HTML_Notification Proc Result : '||result);
7580 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7581 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.PREPARE_HTML_NOTIFICATION', dbg_msg);
7582 END IF;
7583
7584 END IF;
7585 END IF;
7586
7587 EXCEPTION
7588 WHEN OTHERS THEN
7589 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Send_HTML_Notification',
7590 itemtype, itemkey, actid, funmode);
7591 RAISE;
7592
7593 END Prepare_HTML_Notification;
7594
7595 PROCEDURE Set_HTML_Notification_Details
7596 ( p_itemtype IN VARCHAR2,
7597 p_itemkey IN VARCHAR2,
7598 p_actid IN NUMBER,
7599 p_funmode IN VARCHAR2,
7600 p_contact_type IN VARCHAR2,
7601 p_contact_id IN NUMBER,
7602 p_request_id IN NUMBER,
7603 p_request_number IN VARCHAR2,
7604 p_sender IN VARCHAR2,
7605 p_email_preference IN VARCHAR2,
7606 p_user_language IN VARCHAR2,
7607 p_recipient IN VARCHAR2,
7608 p_message_name IN VARCHAR2,
7609 p_from_status IN VARCHAR2,
7610 p_to_status IN VARCHAR2) IS
7611
7612 l_count NUMBER :=0 ;
7613 l_count1 NUMBER :=0 ;
7614 l_ticket_number VARCHAR2(2000);
7615 l_ticket_valid BOOLEAN:= FALSE;
7616 l_request UTL_HTTP.REQ;
7617 l_response UTL_HTTP.RESP;
7618 l_out_value VARCHAR2(32000);
7619 l_ibu_url VARCHAR2(2000);
7620 l_host VARCHAR2(2000);
7621 l_request_number VARCHAR2(240);
7622 l_message_id NUMBER;
7623 l_mail_pref VARCHAR2(240);
7624
7625 BEGIN
7626
7627 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7628 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS')) THEN
7629
7630 dbg_msg := ('In CS_WF_AUTO_NTFY_UPDATE_PKG.Set_HTML_Notification_Details Procedure');
7631 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7632 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS', dbg_msg);
7633 END IF;
7634
7635 END IF;
7636 END IF;
7637
7638 -- Get the ticket number
7639
7640 l_ticket_number := FND_HTTP_TICKET.GET_SERVICE_TICKET_STRING('CS_IBU_EMAIL');
7641
7642 -- Set the mail preference
7643
7644 IF (p_email_preference = 'MAILHTML' OR p_email_preference = 'MAILHTML2') THEN
7645 l_mail_pref := 'MAILHTML';
7646 ELSE
7647 l_mail_pref := 'MAILTEXT';
7648 END IF ;
7649
7650 -- set the ibu url
7651
7652 l_ibu_url := '/OA_HTML/ibuEmailContentProvider.jsp?ibuSRNum='||p_request_number||l_amp||'ibuSRID='
7653 || p_request_id ||l_amp||'ibuTicketNum=' || l_ticket_number || l_amp||'ibuEmailIBUCONTENTPref='
7654 || l_mail_pref || l_amp||'IBUContactID=' || p_contact_id || l_amp||'IBUContactType='
7655 || p_contact_type || l_amp||'IBULanguage=' || p_user_language ;
7656
7657 -- Get the host
7658
7659 FND_PROFILE.GET('APPS_FRAMEWORK_AGENT',l_host);
7660
7661 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7662 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS')) THEN
7663
7664 dbg_msg := ('l_mail_pref : '||l_mail_pref);
7665 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7666 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS', dbg_msg);
7667 END IF;
7668
7669 dbg_msg := ('IBU URL : '||l_host||l_ibu_url);
7670 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7671 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS', dbg_msg);
7672 END IF;
7673
7674 END IF;
7675 END IF;
7676
7677 -- bug 5661159
7678 IF lower(substr(nvl(l_host, ''), 1, 5)) = 'https' THEN
7679 UTL_HTTP.SET_WALLET('file:' || FND_PROFILE.Value('FND_DB_WALLET_DIR'));
7680 END IF;
7681 -- bug 5661159_eof
7682
7683 l_request := UTL_HTTP.BEGIN_REQUEST(l_host||l_ibu_url);
7684
7685 l_response := UTL_HTTP.Get_Response(l_request);
7686
7687 LOOP
7688 l_count := l_count + 1 ;
7689 UTL_HTTP.READ_LINE(l_response, l_out_value,TRUE);
7690
7691 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7692 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS')) THEN
7693 dbg_msg := ('l_count : '||l_count||' l_count1'||l_count1);
7694 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7695 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS', dbg_msg);
7696 END IF;
7697
7698 dbg_msg := ('Response Line : '||substr(l_out_value,1,4000));
7699 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7700 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.SET_HTML_NOTIFICATION_DETAILS', dbg_msg);
7701 END IF;
7702
7703 END IF;
7704 END IF;
7705
7706 IF l_count1 > 0 THEN
7707 l_count1 := l_count1 + 1;
7708 END IF ;
7709
7710 IF l_out_value = 'EMAILCONTENTSTART' THEN
7711 l_count1 := 1;
7712 END IF ;
7713
7714 IF ((length(l_out_value) >0 ) AND(l_mail_pref = 'MAILTEXT')) THEN
7715 l_out_value := REPLACE(l_out_value,'\n',l_new_line);
7716 END IF;
7717
7718 IF l_count1 = 2 THEN
7719
7720 WF_ENGINE.SetItemAttrText(
7721 itemtype => p_itemtype,
7722 itemkey => p_itemkey,
7723 aname => 'STYLESHEET',
7724 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7725
7726
7727 ELSIF l_count1 = 3 then
7728
7729 WF_ENGINE.SetItemAttrText(
7730 itemtype => p_itemtype,
7731 itemkey => p_itemkey,
7732 aname => 'BRANDINGINFO',
7733 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7734
7735 ELSIF l_count1 = 4 then
7736
7737 WF_ENGINE.SetItemAttrText(
7738 itemtype => p_itemtype,
7739 itemkey => p_itemkey,
7740 aname => 'IBU_CONTENT1',
7741 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7742
7743 ELSIF l_count1 = 5 then
7744
7745 WF_ENGINE.SetItemAttrText(
7746 itemtype => p_itemtype,
7747 itemkey => p_itemkey,
7748 aname => 'IBU_CONTENT2',
7749 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7750
7751
7752 ELSIF l_count1 = 6 then
7753
7754 WF_ENGINE.SetItemAttrText(
7755 itemtype => p_itemtype,
7756 itemkey => p_itemkey,
7757 aname => 'IBU_CONTENT3',
7758 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7759
7760
7761 ELSIF l_count1 = 7 then
7762
7763 WF_ENGINE.SetItemAttrText(
7764 itemtype => p_itemtype,
7765 itemkey => p_itemkey,
7766 aname => 'IBU_CONTENT4',
7767 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7768
7769
7770 ELSIF l_count1 = 8 then
7771
7772 WF_ENGINE.SetItemAttrText(
7773 itemtype => p_itemtype,
7774 itemkey => p_itemkey,
7775 aname => 'IBU_CONTENT5',
7776 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7777
7778
7779
7780 ELSIF l_count1 = 9 then
7781
7782 WF_ENGINE.SetItemAttrText(
7783 itemtype => p_itemtype,
7784 itemkey => p_itemkey,
7785 aname => 'IBU_CONTENT6',
7786 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7787
7788
7789
7790 ELSIF l_count1 = 10 then
7791
7792 WF_ENGINE.SetItemAttrText(
7793 itemtype => p_itemtype,
7794 itemkey => p_itemkey,
7795 aname => 'IBU_CONTENT7',
7796 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7797
7798
7799
7800 ELSIF l_count1 = 11 then
7801
7802 WF_ENGINE.SetItemAttrText(
7803 itemtype => p_itemtype,
7804 itemkey => p_itemkey,
7805 aname => 'IBU_CONTENT8',
7806 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7807
7808
7809 ELSIF l_count1 = 12 then
7810
7811 WF_ENGINE.SetItemAttrText(
7812 itemtype => p_itemtype,
7813 itemkey => p_itemkey,
7814 aname => 'IBU_CONTENT9',
7815 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7816
7817
7818 ELSIF l_count1 = 13 then
7819
7820 WF_ENGINE.SetItemAttrText(
7821 itemtype => p_itemtype,
7822 itemkey => p_itemkey,
7823 aname => 'IBU_CONTENT10',
7824 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7825
7826
7827 ELSIF l_count1 = 14 then
7828
7829 WF_ENGINE.SetItemAttrText(
7830 itemtype => p_itemtype,
7831 itemkey => p_itemkey,
7832 aname => 'IBU_CONTENT11',
7833 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7834
7835
7836 ELSIF l_count1 = 15 then
7837
7838 WF_ENGINE.SetItemAttrText(
7839 itemtype => p_itemtype,
7840 itemkey => p_itemkey,
7841 aname => 'IBU_CONTENT12',
7842 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7843
7844
7845 ELSIF l_count1 = 16 then
7846
7847 WF_ENGINE.SetItemAttrText(
7848 itemtype => p_itemtype,
7849 itemkey => p_itemkey,
7850 aname => 'IBU_CONTENT13',
7851 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7852
7853
7854 ELSIF l_count1 = 17 then
7855
7856 WF_ENGINE.SetItemAttrText(
7857 itemtype => p_itemtype,
7858 itemkey => p_itemkey,
7859 aname => 'IBU_CONTENT14',
7860 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7861
7862
7863 ELSIF l_count1 = 18 then
7864
7865 WF_ENGINE.SetItemAttrText(
7866 itemtype => p_itemtype,
7867 itemkey => p_itemkey,
7868 aname => 'IBU_CONTENT15',
7869 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7870
7871
7872 ELSIF l_count1 = 19 then
7873
7874 NULL;
7875 ELSIF l_count1 = 20 then
7876
7877 IF l_count1 IS NOT NULL THEN
7878 WF_ENGINE.SetItemAttrText(
7879 itemtype => p_itemtype,
7880 itemkey => p_itemkey,
7881 aname => 'URL_LINK',
7882 avalue => 'plsql:IBU_SUBS_DOC_PKG.set_msg_body_token/'||l_out_value );
7883
7884 END IF;
7885 END IF ;
7886
7887 IF l_out_value = 'EMAILCONTENTEND' THEN
7888 EXIT;
7889 END IF;
7890
7891 END LOOP;
7892
7893 UTL_HTTP.End_Response(l_response);
7894
7895 EXCEPTION
7896 WHEN UTL_HTTP.END_OF_BODY THEN
7897 UTL_HTTP.End_Response(l_response);
7898 WHEN OTHERS THEN
7899 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Verify_Notify_Rules_Done',
7900 p_itemtype, p_itemkey, p_actid, p_funmode);
7901 RAISE;
7902 END Set_HTML_Notification_Details;
7903
7904 PROCEDURE Are_All_HTML_Recips_Notified( itemtype IN VARCHAR2,
7905 itemkey IN VARCHAR2,
7906 actid IN NUMBER,
7907 funmode IN VARCHAR2,
7908 result OUT NOCOPY VARCHAR2 ) IS
7909
7910
7911 l_contact_id_list VARCHAR2(2000);
7912
7913 BEGIN
7914
7915 IF((FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)) THEN
7916 IF (FND_LOG.TEST(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.ARE_ALL_HTML_RECIPS_NOTIFIED')) THEN
7917
7918 dbg_msg := ('In CS_WF_AUTO_NTFY_UPDATE_PKG.Are_All_HTML_Recips_Notified Procedure');
7919 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7920 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.ARE_ALL_HTML_RECIPS_NOTIFIED', dbg_msg);
7921 END IF;
7922
7923 dbg_msg := ('l_contact_id_list : '||l_contact_id_list);
7924 IF( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
7925 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'cs.plsql.CS_WF_AUTO_NTFY_UPDATE_PKG.ARE_ALL_HTML_RECIPS_NOTIFIED', dbg_msg);
7926 END IF;
7927
7928 END IF;
7929 END IF;
7930 IF (funmode = 'RUN') THEN
7931
7932 l_contact_id_list := WF_ENGINE.GetItemAttrText(
7933 itemtype => itemtype,
7934 itemkey => itemkey,
7935 aname => 'CONTACT_ID_LIST' );
7936
7937 IF (l_contact_id_list IS NOT NULL ) THEN
7938 result := 'COMPLETE:N';
7939 ELSE
7940 result := 'COMPLETE:Y';
7941 END IF ;
7942
7943
7944 ELSIF (funmode = 'CANCEL') THEN
7945 result := 'COMPLETE';
7946 END IF;
7947
7948 EXCEPTION
7949 WHEN OTHERS THEN
7950 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Are_All_HTML_Recips_Notified',
7951 itemtype, itemkey, actid, funmode);
7952 RAISE;
7953
7954 END Are_All_HTML_Recips_Notified;
7955
7956 PROCEDURE Create_Role_List
7957 ( p_itemtype IN VARCHAR2,
7958 p_itemkey IN VARCHAR2,
7959 p_actid IN NUMBER,
7960 p_funmode IN VARCHAR2,
7961 p_action_code IN VARCHAR2,
7962 p_role_group_type IN VARCHAR2,
7963 p_role_group_code IN VARCHAR2) IS
7964
7965 l_party_role_group_code cs_party_role_group_maps.party_role_group_code%TYPE;
7966 l_part_role_code cs_party_role_group_maps.party_role_code%TYPE;
7967 l_notify_party_role_list varchar2(4000);
7968 l_notify_party_role_relsr_list varchar2(4000);
7969
7970 CURSOR sel_party_role_csr IS
7971 SELECT party_role_code
7972 FROM cs_party_role_group_maps
7973 WHERE party_role_group_code = l_party_role_group_code
7974 AND trunc(sysdate) between trunc(nvl(start_date_active,sysdate))
7975 and trunc(nvl(end_date_active,sysdate));
7976
7977 sel_party_role_rec sel_party_role_csr%ROWTYPE;
7978
7979 BEGIN
7980 --x_return_status := FND_API.G_RET_STS_SUCCESS;
7981
7982 IF (p_action_code = 'NOTIFY_ASSOCIATED_PARTIES') THEN
7983 IF (p_role_group_type = 'ROLEGROUP') THEN
7984 l_party_role_group_code := p_role_group_code;
7985
7986 OPEN sel_party_role_csr;
7987 LOOP
7988 FETCH sel_party_role_csr into sel_party_role_rec;
7989 EXIT WHEN sel_party_role_csr%NOTFOUND;
7990
7991 -- Check for the length, not to exceed max WF text length of 4000.
7992
7993 IF (nvl(LENGTH(l_notify_party_role_list), 0) +
7994 nvl(LENGTH(sel_party_role_rec.party_role_code), 0) + 1) <= 4000 THEN
7995
7996 IF l_notify_party_role_list IS NULL THEN
7997 l_notify_party_role_list := sel_party_role_rec.party_role_code;
7998 ELSE
7999 l_notify_party_role_list := l_notify_party_role_list || ' ' || sel_party_role_rec.party_role_code;
8000 END IF;
8001 ELSE
8002 /**********
8003 If the query results exceeded the max allowable WF text length, then we
8004 set an attribute to indicate that we need to re-query again to obtain
8005 the remainder of the results which were not put in the initial list.
8006 **********/
8007
8008 WF_ENGINE.SetItemAttrText
8009 (itemtype => p_itemtype,
8010 itemkey => p_itemkey,
8011 aname => 'MORE_NTFY_ACTION_LIST',
8012 avalue => 'Y' );
8013
8014 END IF;
8015 END LOOP;
8016 CLOSE sel_party_role_csr;
8017 ELSE --(sel_action_rec.role_group_type = 'ROLEGROUP') THEN
8018 l_party_role_group_code := p_role_group_code;
8019
8020 IF (nvl(LENGTH(l_notify_party_role_list), 0) +
8021 nvl(LENGTH(l_party_role_group_code), 0) + 1) <= 4000 THEN
8022
8023 IF l_notify_party_role_list IS NULL THEN
8024 l_notify_party_role_list := l_party_role_group_code;
8025 ELSE
8026 l_notify_party_role_list := l_notify_party_role_list || ' ' || l_party_role_group_code;
8027 END IF;
8028
8029 ELSE
8030 /**********
8031 If the query results exceeded the max allowable WF text length, then we
8032 set an attribute to indicate that we need to re-query again to obtain
8033 the remainder of the results which were not put in the initial list.
8034 **********/
8035
8036 WF_ENGINE.SetItemAttrText
8037 (itemtype => p_itemtype,
8038 itemkey => p_itemkey,
8039 aname => 'MORE_NTFY_ACTION_LIST',
8040 avalue => 'Y' );
8041
8042 END IF;
8043 END IF; --(sel_action_rec.role_group_type = 'GROUP') THEN
8044
8045 ELSIF (p_action_code = 'NOTIFY_ALL_ASSOCIATED_PARTIES') THEN
8046 IF (p_role_group_type = 'ROLEGROUP') THEN
8047 l_party_role_group_code := p_role_group_code;
8048
8049 OPEN sel_party_role_csr;
8050 LOOP
8051 FETCH sel_party_role_csr into sel_party_role_rec;
8052 EXIT WHEN sel_party_role_csr%NOTFOUND;
8053
8054 -- Check for the length, not to exceed max WF text length of 4000.
8055 IF (nvl(LENGTH(l_notify_party_role_relsr_list), 0) +
8056 nvl(LENGTH(sel_party_role_rec.party_role_code), 0) + 1) <= 4000 THEN
8057
8058 IF l_notify_party_role_relsr_list IS NULL THEN
8059 l_notify_party_role_relsr_list := sel_party_role_rec.party_role_code;
8060 ELSE
8061 l_notify_party_role_relsr_list := l_notify_party_role_relsr_list || ' ' || sel_party_role_rec.party_role_code;
8062 END IF;
8063
8064 ELSE
8065 /**********
8066 If the query results exceeded the max allowable WF text length, then we
8067 set an attribute to indicate that we need to re-query again to obtain
8068 the remainder of the results which were not put in the initial list.
8069 **********/
8070
8071 WF_ENGINE.SetItemAttrText
8072 (itemtype => p_itemtype,
8073 itemkey => p_itemkey,
8074 aname => 'MORE_NTFY_ACTION_LIST',
8075 avalue => 'Y' );
8076
8077 END IF;
8078
8079 END LOOP;
8080 CLOSE sel_party_role_csr;
8081 ELSE --(sel_action_rec.role_group_type = 'ROLEGROUP') THEN
8082 l_party_role_group_code := p_role_group_code;
8083
8084 IF (nvl(LENGTH(l_notify_party_role_relsr_list), 0) +
8085 nvl(LENGTH(l_party_role_group_code), 0) + 1) <= 4000 THEN
8086
8087 IF l_notify_party_role_relsr_list IS NULL THEN
8088 l_notify_party_role_relsr_list := l_party_role_group_code;
8089 ELSE
8090 l_notify_party_role_relsr_list := l_notify_party_role_relsr_list || ' ' || l_party_role_group_code;
8091 END IF;
8092
8093 ELSE
8094 /**********
8095 If the query results exceeded the max allowable WF text length, then we
8096 set an attribute to indicate that we need to re-query again to obtain
8097 the remainder of the results which were not put in the initial list.
8098 **********/
8099
8100 WF_ENGINE.SetItemAttrText
8101 (itemtype => p_itemtype,
8102 itemkey => p_itemkey,
8103 aname => 'MORE_NTFY_ACTION_LIST',
8104 avalue => 'Y' );
8105
8106 END IF;
8107 END IF; --(sel_action_rec.role_group_type = 'ROLEGROUP') THEN
8108
8109 END IF;
8110
8111 WF_ENGINE.SetItemAttrText
8112 (itemtype => p_itemtype,
8113 itemkey => p_itemkey,
8114 aname => 'NOTIFY_PARTY_ROLE_LIST',
8115 avalue => l_notify_party_role_list );
8116
8117 WF_ENGINE.SetItemAttrText
8118 (itemtype => p_itemtype,
8119 itemkey => p_itemkey,
8120 aname => 'NOTIFY_RELSR_PARTY_ROLE_LIST',
8121 avalue => l_notify_party_role_relsr_list );
8122
8123 EXCEPTION
8124 WHEN OTHERS THEN
8125 WF_CORE.Context('CS_WF_AUTO_NTFY_UPDATE_PKG', 'Create_Role_List',
8126 p_itemtype, p_itemkey, p_actid, p_funmode);
8127 RAISE;
8128 END Create_Role_List;
8129
8130 END CS_WF_AUTO_NTFY_UPDATE_PKG;