Now we know how to put a place holder for approver comments.Now we will learn how we can provide a list of values, so that approver can select a possible values from the drop down.
Basic Requirement
Our old requirement looks like "when a person applies for a leave, it should go his/her supervisor for approval. Approver must be able to provide his/her comments for approval or rejection of the requisition(comments is optional).and once it is approved save the information in database . If the leave gets rejected, don’t store any information in database."
Now we will change our requirement a bit. It is as mentioned below
"when a person applies for a leave it should go his/her supervisor for approval. Approver must be able to provide his/her comments for approval or rejection of the requisition(comments optional). Approver must also be able to select the Organization Leave Type from a list of values . If the leave gets rejected, don’t store any information in database."
The possible "Organization Leave Type" list of values are
1) Medical Leave
2) Personal Unpaid Leave
3) Personal Paid Leave
(Change requirement is in bold)
Design Appraoch
To implement the above requirement, we have to perform the following steps to update the existing workflow definition
1) As we know Lookup-type/lookup-code provides us the static list of values. Hence first we have to create a lookup type that will hold all the "Organization Leave Type" as lookup code.
a) Create a lookup type
Internal Name:- APPROVER_LEAVE_TYPE
Display Name:- Approver Leave Type
b) Create lookup code as mentioned below
1) Medical Leave
Internal Name:- MEDICAL_LEAVE
Display Name:- Medical Leave
2) Personal Unpaid Leave
Internal Name:- PERSONAL_UNPAID_LEAVE
Display Name:- Personal Unpaid Leave
3) Medical Leave
Internal Name:- PESONAL_PAID_LEAVE
Display Name:- Personal Paid Leave
4) Create another lookup code
Internal Name:- NULL
Display Name:- -----Null-----
( The reason of this 4th lookup code will be discussed later on**)
2) Now our lookup type and lookup code is created. We have create a item-attribute of type lookup and we will attach this lookup to the item attribute.
3) Since we need to make this attribute available to approver, so we have make it also a message attribute. we will also take the input from approver. Thus this item attribute must be a message attribute with Source as "Respond"
Copy the item attribute and paste it in the message. Open the attribute and make the Source as "Respond". Also ensure that we have Default value Type "Constant" and Value is "----Null----".
4) Our Design is ready to test. Validate the design and save it to database.
5) Now trigger the workflow and Check the notification with approver.
** Note:-
1) We have created additional lookup code as 'NULL' (Remember here NULL is also a value) and make it a default value of the item attribute and message
attribute as well.
If don't select any default value and keep it as blank (No value). Then in application approver will see no default value in the field. Since our field is not a mandatory field, and hence supervisor can left the field as it is and try to approve or reject the requisition. If the field remains blank, then supervisor will receive an application error. Hence we have created a additional lookup code "-----Null-----"
2) Since lookup code NULL doesn't corresponds to database NULL (Blank), Hence it is responsibility of the developer to decode it and re-set the value to
NULL(Blank).