1) open workflow builder tool and connect to data base.
2) search for "standard" workflow
3) drag this to left hand side as below and click ok.
4)Right click on standard and click on new then Item type
5) give name and description And save
6)right click on process and New process. give details and save.
7) right click on attribute and new attribute. give details and save.
8) right click on message and new message. give all details and save.
9) go to result tab of the above window. select this details and save.
10) after creating message.Add comments attribute from attribute and paste it in the message and select attribute as respond type.
11) click on notification and new notification. give details and save.in this window select function as pl sql package and procedure name where we will write logic to make comments field mandatory.
12) Click on process, it will open blank window like below
13) copy start and end function from standard workflow and paste it under custom workflow function section.
drag both function to the process window
14) drag notification also in this window and connect these icons with each other as below and apply:
15) click on start activity and go to node tab. select value as start from drop down as below:
16) click on End activity and go to node tab. select value as end from drop down as below and Apply:
17) now workflow builder part is finished. Now we will see pl/sql part. first create sequence named as XX_SEQ in the data base which will be used to store item key value. This is the code below
CREATE OR REPLACE PACKAGE BODY XX_DEMO IS
PROCEDURE LAUNCH_WORKFLOW
IS
v_master_form_link varchar2(5000);
v_item_number varchar2(100);
v_add_item_id varchar2(5000);
error_code varchar2(100);
error_msg varchar2(5000);
v_item_key VARCHAR2(10) := to_char(xx_SEQ.nextval);
v_item_type varchar2(10) := 'XX_TEST';
v_process varchar2(20) := 'XX_PROC';
BEGIN
WF_ENGINE.CREATEPROCESS(v_item_type, v_item_key, v_process);
WF_ENGINE.STARTPROCESS(v_item_type, v_item_key);
commit;
EXCEPTION
WHEN OTHERS THEN
error_code := SQLCODE;
error_msg := SQLERRM(SQLCODE);
-- add dbms or fnd_output messages as required
END LAUNCH_WORKFLOW;
procedure check_comment_reject(ITEMTYPE IN VARCHAR2,
ITEMKEY IN VARCHAR2,
ACTID IN NUMBER,
FUNCMODE IN VARCHAR2,
RESULTOUT IN OUT VARCHAR2) is
l_notfication_result varchar2(1000);
l_sup_comments varchar2(10000);
begin
if (FUNCMODE = 'RESPOND') then
l_notfication_result := wf_notification.getAttrText(wf_engine.context_nid,
'RESULT');
l_sup_comments := wf_notification.GetAttrText(nid => wf_engine.context_nid,
aname => 'XX_COMMENT');
if (l_notfication_result = 'REJECTED') then
if l_sup_comments is null then
raise_application_error('-20002',
'Comments are mandatory while rejecting request');
else
RESULTOUT := 'COMPLETE:REJECT';
end if;
elsif (l_notfication_result = 'APPROVED') then
RESULTOUT := 'COMPLETE:APPROVE';
end if;
WF_ENGINE.SetItemAttrText(ITEMTYPE,
ITEMKEY,
'XX_COMMENT',
l_sup_comments);
end if;
exception
when others then
wf_core.context('XX_DEMO',
'check_comment_reject',
ITEMTYPE,
ITEMKEY,
ACTID,
FUNCMODE);
raise;
end;
END XX_DEMO;
Now if you are facing any difficulty, please put in comments, will respond you on the same.
No comments:
Post a Comment