Thursday, September 28, 2017

Custom Workflow Development

c) Custom Workflow Development

Our Custom workflow design in pen and paper is almost finalized (Refer our previous discussion  Requirement Mapping & Custom Workflow Design ). We are also ready with the probable list of Workflow components.
Now we will proceed with the step-wise development of our custom workflow.

Design Components

To design our discussed custom workflow, we need to create following workflow components
Item Attribute
1)      Requestor person id            (Type-Number)
2)      Requestor User name         (Type-Text)
3)      Requestor full name           (Type-Text)
4)      Leave Type                         (Type-Text)
5)      Leave from date                 (Type-Date)
6)      Leave to date                      (Type-Date)
7)      Supervisor person id           (Type-Number)
8)      Supervisor User name        (Type-Text)
9)      Supervisor full name          (Type-Text)
Lookup Type/Code
Lookup code a) Approve b) Reject
Lookup Type:- APPROVE_REJ

Function Activity
1) Start (Type:- START)
2) End  (Type END)

Message
Message to Supervisor with the details of the applied leave.

Notification
notification to send message to supervisor and approve or reject the same.
Workflow Development
Now we will proceed with the stepwise development of workflow process and its components.

1) Open workflow Builder.Click on the Hammer icon to open it in Developer mode.


2) Click on the New icon, It will open up a pop-up window to create a item-type.
    Internal Name:- XX_TEST
    Display Name:- Test Leave Workflow
Keep the other filed as it is(with its default value-as shown in picture)


Note:-  1) We can also use the Quick start Wizard.Quick Start Wizard will help us to creates our new item type and new process activity.
           2) The persistence type controls how long a status audit trail is maintained for each instance of the item type. 
              If we set Persistence to Permanent, the runtime status information is maintained indefinitely until you specifically purge the information by calling the
              procedure WF_PURGE.TotalPerm().

              If we set an item type's Persistence to Temporary, we must also specify the number of Defining Workflow Process days of persistence ('n'). The status
              audit trail for each instance of a Temporary item type is maintained for at least 'n' days of persistence after its completion date. After the 'n' days of
              persistence, we can then use any of the WF_PURGE APIs to purge the item type's runtime status information.


Here we are keeping Persistence to 'Temporary' and Number of Days to Zero(0).

3) Now to create Item Attribute, Right click on the "Attribute" and select 'New Attribute', it will open up a pop-up window which will help us to create item attribute
 


Internal Name:- LEAVE_FROM_DATE
Display Name:- Leave From Date
Type:-              Date

Keep other field as it is
.
Define the other listed item attributes as mentioned above.

4) Now to create Item lookup Types/code, Right click on the "Item Types" and select 'New', it will open up a pop-up window which will help us to create Lookup Type
Internal Name :- APPROVE_REJ
Display Name :- Approve or Reject

Keep the field and other tabs as it is,

Now select the newly created Lookup Type (i.e, APPROVE_REJ) and richt click on it & select 'New Lookup Code'. It will open up a pop-up window that will help us to create new lookup code.
Internal Name:- APPROVE
Display Name:- Approve

In a similar ways create the other lookup code(REJECT).

5) To create a message Right click on the "Message" in Navigator window and click on "New Message", it will open up a pop-up window that will help us to craete a new message.
Internal Name:- XX_TEST_APPROVER_MESSAGE
Display Name:- test Leave Approver Message
Priority          :- Normal




Select the Subject Line and the body of the message. Body of the message can be in 'Plain Text Mode' or in HTML mode.
Subject Line:-Leave Approval for person &REQUESTER_EMP_NAME(&REQUESTER_EMP_NO)
Body:- A sample body is given below.

Dear <b>&SUP_EMP_NAME</b>,
    The person &REQUESTER_EMP_NAME(&REQUESTER_EMP_NO) has submitted leave requisition. Request you please take necessary action on the requisition.
<br></br>
<u>Leave Details</u>
<table>
<tr><td>Leave Type</td><td>Start Date</td><td>End Date</td></tr>
<tr>td>&LEAVE_TYPE</td><td>&LEAVE_FROM_DATE</td><td>&LEAVE_TO_DATE</td></tr>
</table>
<br></br>
Regards
HR Team

Here we have used Token substitute an attribute.The method of doing this &<Internal name of Attribute>. In runtime Workflow replaces those(As mentioned in bold) with the corresponding attribute value.






Note:- To Token substitute an attribute, we have to make those attribute as message attribute. To make a attribute available in message copy the respective item-attribute and paste it in message. All the message attribute will appear under the respective message.Keep the source as 'Send'. It means we are sending the value of the attribute to the performer of the notification(to which th message is attached).
If the source is 'Respond', it means we want the value from the responder(will be discussed in detail later).



In our example Supervisor either can approve the leave requisition or Reject the same. Hence we have provide the supervisor two result button (APPROVE ; REJECT). To create the button click on the result tab(as shown in the picture) above and the add the desired lookup type. Workflow will automatically place the buttons in run time.

Provide the following details

Display Name:- Approve/Reject
Lookup Type:- Approve Or Reject

6) To create notification right click on the "Notifications" and select "New Notifications". It will open a pop-up window that will help us to create a Notification

Internal Name:- XX_TEST_LEAVE_NOTIF
Display Name:- Test Leave Notification
Message:- Attach the newly created message.
Result Type:- Since our notification will go to Supervisor and he/she can approve/reject leave requisition.Thus we need to have two different transition from the notification. Because of this we need to attach our newly created Lookup type.

Keep the other tabs as it is,


Note:- 1) Check Expand Roles to send an individual copy of the notification message to each user in the role. The notification remains in a user's notification queue
             until the user responds to or closes the notification.

             one should expand roles to send out a broadcast-type/FYI type(message that don't require any response from performer) message for which he/she wants
             all users of that role to see.Otherwise if one user from the roles closes the notification, it will be closed from all the other users.

          2) Here we don't have any option to attach performer with the notification. It will be available once we use the notification in the process.

7) To create a Function activity, right click on "Function" and select "New Function". It will opens up a pop-up window which will help us to create function.
Internal Name:- START
Display Name:- Start
Function Name:- WF_STANDARD.NOOP**
Function Type:- PL/SQL
Result Type:- <None>(keep 
default value as it is)
Cost          :- 0.00( Keep default value as it is)
** => WF_STANDARD.NOOP is oracle provided Seeded package.procedure mainlly used as Pl/Sql procedure for Start and End activity.
Note:- Here we don't have any option to mark the function as 'START' or 'END'. This can be done once we use the same in a process.

8) Now to create Workflow process right click on "Processes" in Navigation Tree and select "New Process". It will pop-up a window which will help us to define process.

Internal Name:-XX_TEST_PROC
Display Name:- Test Leave Approval Process
Result Type:- <None>(Keep the default value as it is)
Runnable:- Checked.

Note:- Check Runnable so that the process that this activity represents can be initiated as a top-level process and run independently.
           If process activity represents a subprocess that should only be executed if it is called from a higher level process,then uncheck Runnable.

9) Till the point 8 we have discussed, how we can define each workflow components. Now we have bind them together to create a workflow process.
    a) Double click on the newly created icon, it will open up a process window.Resize the window so that both the window(Navigator, process window) as shown in
        the figure below.


   
  b) First "Drag & Drop" START  & END Function activity to Process window. Once it is appear in process window, double click on the icon, it will open up the
     Function activity window. Go to "Node" tab and select 'Start' for START activity in 'Start/End' field.(As shown in picture below.)
     Do the same for END Activity.(Select 'End' in 
'Start/End' field.)


Note
:-Start and End activity can be distinguished by the following identification mark
         Start activities are marked with a small green arrow
         End activities by a red arrow.
 


  c) Now drag the notification from Navigator window to process window and double click on the notification icon. A notification properties details
      window will open up
.
       As mentioned, we need to add performer in the notification.
         Go to "Node" tab of the property window. Go to the Performer Section.
      Type :- "Item Attribute" &
      Value:-"Supervisor User Name".




      d) Now we need to make transition between different activity. To create transition between source and destination hold down right mouse button and drag your
          mouse from a source activity to destination activity
.
           
            Note:- 1) If the source activity has no result code associated with it, then by default, no label appears on the transition.

                      2) If the source activity has a result code associated with it, then a list of lookup values appears when you attempt to create a transition to the
                         destination activity. Select a value to assign to the transition. You can also select the values <Default>, <Any>, or <Timeout> to define a
                         transition to take if the activity returns a result that does not match the result of any other transition, if the activity returns any result, or if the
                        activity times out, respectively
.


Saving Workflow Definition
1) Our workflow is ready to save it in database. Before saving it to database we must validate the definition.




2) Once the definition is validated, go to File >> Save. It will open up a pop-up window with the save option (database or Local). Select the database option and provide the database credentials to save.



Our Custom Workflow is now ready to be triggered. The triggering mechanism will be discussed in next topic.

References:-   1)  Oracle® Workflow Developer's Guide
                              Release 12
                              Part No. B31433-04

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_...