This topic, we will extend feature of book Identity Manager
Volume II: Learn by Example code chapter 10 workflow and approval. We want to
customize display of work list.
Requirement
We want to change default display
of work list from workflow as figure below
- Change content: format Date + customized message + who request
- Change layout as bullet
Figure 1 shows the expected result
Design
The
default work item display as table in picture below:
Figure 2 shows default display of work list
Each record came
from WorkItem object that generated by workflow’s job.
Column
|
WorkItem
|
Workflow
|
Status
|
WorkItem.getState()
|
WorkItemEntry.getWorkStateID()
|
Name
|
WorkItem.getName()
|
Node Name
|
WorkItem.getTitle()
|
Job Data:
nete.NISProcessTitle
|
|
Last
Update On
|
WorkItem.getLastUpdateDate()
|
WorkItemEntry.getLastUpdateDate()
|
Initiated By
|
WorkItem. getInitiator()
|
Job Data: Initiator
|
Workflow
Level
|
WorkItem.getMapLevel()
|
Job Data: mapping-level
|
We are interested to customized
column Name. We can modify WorkItem.getTitle. You can check workflow job data:
nete.NISProcessTitle.
Please run workpoint designer and
click some job and does the right on canvas of workflow. Select tab User Data,
you will see Job Data “nete.NISProcessTitle”. This value usually came from
event description.
Figure 3 shows Job’ User Data
So we have to write script to modify Job’s User Data. I
suggest writing script in synchronous agent, it is pretty easy.
Unfortunately,
column name came from WorkItem.getName() +”-”+WorkItem.getTitle(). The result
is still in format picture below.
Figure 4 shows Job’ User Data
|
If you
still do not like it, you have to go customized layout.
Implementation
We extend workflow from chapter 10
workflow and approval. You will learn 2
examples:
- § How to customized work list’s name (or Job’s User Date nete.NISProcessTitle
- § How to customized layout
Customized Work List’s Name
Code
1. Import
our code ModifyTaskTitle .java to eclipse
2. Export
to custom folder (include package “com.book.idm.bonus.worklist”)
WorkPoint Configuration
1. Run
WorkPoint Designer
2. Select
menu “Open Process” and select “Project : Request CRM Application” (chapter 10)
3. Select
node “Approver”
4. Select
tab: Agents and click new script icon
§
Tab: General
o
Put name: Bonus.modifyTaskTitle
§
Tab:
Agents
o
Statement Type: Java
o
Java Class: com.book.idm.bonus.worklist.CustomizedWorkList
o
Method: modifyTaskTitle
o
Parameters: ClientContext,ThisJobData
§
Tab: Category (Optional)
o
Select “BookProject”
Figure 5 shows script details
|
1. Add
script to Synchronous
Figure 6 add script to Synchronous
|
1. Click
ok button and save process.
How it works
1. Log
into the Identity Manager User Console as administrator.
2. Select
tab: Book Example, select menu Project, and task Request Application
3. Put
the correct employee number, and select CRM application, and then clicks
submit.
Figure 7 shows screen to
request application for employee.
|
Figure
8 shows customized column “Name”
|
The message value has been changed from “Modify User” to be “Request Application”
Modify
Job’s User Data
Our
agent’s script put value to jobData by using key “nete.NISProcessTitle”. We use
constants IWorkflowConstants.WF_PROP_PROCESS_TITLE
that equals “nete.NISProcessTitle”.
public class
CustomizedWorkList {
public void
modifyTaskTitle(ClientContext clientContext,JobData thisJobData){
WorkflowContext workflowContext = null;
try{
workflowContext = WorkpointHelper.getWorkflowContext(clientContext,
thisJobData);
if(workflowContext.getAdminTask().getTaskTag()
.equalsIgnoreCase(Constants.TASK.REQUEST_APP_TAG)){
User user = WorkpointHelper.getUserByEventContext(workflowContext);
//IWorkflowConstants.WF_PROP_PROCESS_TITLE =
nete.NISProcessTitle
thisJobData.setUserData(IWorkflowConstants.WF_PROP_PROCESS_TITLE,
"Request
Application for "+user.getFriendlyName()); }
}catch(Exception e){
DisplayUtils.addAdminMessage(workflowContext,
e);
}
}
}
|
Depending
on your requirement, this code checks admin task tag before setting title.
Customized Layout
The message shows “Approver – Request Application for user”. If you do not want “Approver”, you
have to customize JSP renderer.
The
work lists are renderer by JSP named “worklist_body.jsp”
// Write it out
listDisplay.write(request, out,
worklist.getResultSet());
|
We
have to comment this part and render by your code.
Code
1. Backup
or rename file “worklist_body.jsp” in folder <identity minder
ear>/user_console.war/app/page.
2. Copy
worklist_body.jsp from download code to folder <identity minder
ear>/user_console.war/app/page.
How it works
Log into the Identity Manager User
Console as approver, if your screen not refresh, some application requires
restart or redeploy application.
Figure
9 shows new customized render
|
Worklist_body.jsp
We
comment the default render part. We get initial date, title and initiator
fromWorkItem.
// Write it out
//listDisplay.write(request, out,
worklist.getResultSet());
Vector<IWorkItem> workItems = worklist.getResultSet();
for(IWorkItem
workItem: workItems){
SimpleDateFormat dateFormat = new
SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String reqDate =
dateFormat.format(workItem.getInitiationDate());
String delegateURL =
workItem.getDelegatedFromDN().equals("")?"":"&delfrom="+workItem.getDelegatedFromDN();
String link = "?task.wfitem="+
URLEncoder.encode(workItem.getId().toString())+delegateURL;
String requester =
workItem.getInitiator();
out.println("<img
src='../../im_help/topic.gif'>"+reqDate+": <a
href='"
+link+"'>"+workItem.getTitle()+"</a>
by "+requester+"<br/>");
}
|
The
interesting point is a link, we have to generate URL starts from “?task.wfitem=”.
Conclusion
This article we learned:
§
How to customized Work List’s Name
§
How to customized Layout
The official document does not give
exactly detail how to customize work list, so use this solution with your own
risk. Please test this code both performance and functional issues. If you still have any questions please send me
an email.
No comments:
Post a Comment