Thursday, September 28, 2017

Triggering a custom workflow

d) Triggering a custom workflow

We are ready with our custom workflow definition and saved in database(Ref:- Custom Workflow Development ).Now we have to prepare pl/sql procedure that will trigger our custom workflow.Our custom workflow will be triggered when it(pl/Sql procedure) will be called by any other processes(viz. from a web page or from any other  pl/sql procedure etc). 

The input parameter of this process must be as mentioned below.
1)    Person Id :- person id of the person who has submitted the request
2)    Leave Type:- Type of leave person has applied
3)    Leave From Date:- Start date of leave
4)    Leave to Date:- End date of leave


We are taking input to ensures that we received all the information that user entered in web page application and required for workflow process.
Item Key
When  a workflow is triggered,It creates a instance of the workflow definition. To identify the instance of the workflow a string is required.  The string that uniquely identifies the instance of the workflow definition is known as item-key. Item-key can be alpha-numeric.

Note:-  Different item-type can have same item-key but for same item-type it is unique. Analogy can be drawn with concurrent program internal name and request id.

Development of Custom Procedure
The following tasks needs to be performed to trigger  a custom workflow successfully
1) Create the process
2) Set attribute values
3) Start the process
4) commit transaction

1) Create the process
Oracle provided us  API to create the instance of the workflow definition process.
wf_engine.createprocess(itemtype => <Internal name of item type>,
                                                itemkey  => <Item key value>,
                                                process  => <Internal name of process>
                                              );

Here v_process should be internal name of runnable process.Here it is ‘XX_TEST_PROC’.

2)Set attribute values

Once the process is created, it actually creates the instance of the workflow definition. Once the instance is created, we need to set attribute values. To set the attribute values we need to call oracle provided workflow apis
wf_engine.SetItemAttrText(itemtype => <Internal name of item type>,
                                           itemkey  => <Item key value>,
                                           aname    =><Internal name of attribute>,
                                           avalue   =><Attribute value that need to set>);
wf_engine.SetItemAttrDate(itemtype => <Internal name of item type>,
                                           itemkey  => <Item key value>,
                                           aname    =><Internal name of attribute>,
                                           avalue   =><Attribute value that need to set>);
wf_engine.SetItemAttrnumber(itemtype => <Internal name of item type>,
                                                itemkey  => <Item key value>,
                                                aname    =><Internal name of attribute>,
                                                avalue   =><Attribute value that need to set>);


3)Start the process

wf_engine.startprocess(<Internal name of item type>type, <Item key value>);

4) Commit Transactions

commit;


Triggering Workflow from a pl/Sql block
Instead of trigerring workflow from a Web-page just for sake of  illustration we will trigger workflow from a pl/sql block by passing necessary parameter values to our  TRIGGER_WORKFLOW procedure.
 
DECLARE
BEGIN
XX_TEST_LEAVE_PKG.TRIGGER_WORKFLOW(P_PERSON_ID        => 14760
                                  ,P_LEAVE_TYPE       => 'Seek Leave'
                                  ,P_LEAVE_FROM_DATE  => '01-MAR-2011'
                                  ,P_TO_DATE          => '04-MAR-2011'
                                  );
END;
 
 
Once the above block is exceuted it will trigger the custom workflow and notification will go to the approver for approval.
Please see the screen shot below
 
 
To track the present status of the workflow follow the below mentioned navigation.
Login as (Sysadmin) >> Workflow Administrator Web Applications >> Status Monitor>>
 
Enter the internal name of  item type of your workflow under "Type Internal Name" and click on "GO". You will find the list of workflows that was triggered. Select any of them and click on View Diagram.
 
 
 
 
ċ
XX_TEST_LEAVE_PKG.pkg 
(6k)

No comments:

Post a Comment

Oracle Fusion - Cost Lines and Expenditure Item link in Projects

SELECT   ccd.transaction_id,ex.expenditure_item_id,cacat.serial_number FROM fusion.CST_INV_TRANSACTIONS cit,   fusion.cst_cost_distribution_...