Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
wt.fc.collections.WTArrayList auditCol = (wt.fc.collections.WTArrayList) wt.workflow.engine.WfEngineHelper.service.getVotingEvents((wt.workflow.engine.WfProcess)self.getObject(), null, null, null);
while( auditEvents.hasNext())
{
wt.workflow.engine.WfVotingEventAudit audit = (wt.workflow.engine.WfVotingEventAudit)auditEvents.next();
System.out.println("***Transition Expression: User vote = " + audit.getEventList());
System.out.println("***Transition Expression: User comment = " + audit.getUserComment());
comments += audit.getUserComment();
System.out.println("***Transition Expression: Complete Time = " + audit.getPersistInfo().getCreateStamp());
}
System.out.println("comments = " + comments);
I verified that the code from Yogesh works, as long as you put the code into an Expression Robot just following the task activity from which you want to retrieve the user-entered comments.
Thanks for the code snippet, Yogesh.
Benjamin Wilcox - IntelliServ<sup>™</sup>
PPM & PDM Administrator
In Reply to Yogesh Bagul:
wt.fc.collections.WTArrayList auditCol = (wt.fc.collections.WTArrayList) wt.workflow.engine.WfEngineHelper.service.getVotingEvents((wt.workflow.engine.WfProcess)self.getObject(), null, null, null);
while( auditEvents.hasNext())
{
wt.workflow.engine.WfVotingEventAudit audit = (wt.workflow.engine.WfVotingEventAudit)auditEvents.next();
System.out.println("***Transition Expression: User vote = " + audit.getEventList());
System.out.println("***Transition Expression: User comment = " + audit.getUserComment());
comments += audit.getUserComment();
System.out.println("***Transition Expression: Complete Time = " + audit.getPersistInfo().getCreateStamp());
}
System.out.println("comments = " + comments);
Dear all,
If you have got this code to work. Could you supply the complete code? I am getting an error about unknown auditEvents variable.
Thanks in advance.
Regards
Gautham
Dear Ben,
Thanks for your reply.
Without any change to the code from above, I get the following error
/ptc/Windchill_101/Windchill/tmp/WfExpression88659.java:39: cannot find symbol
symbol : variable auditEvents
location: class wt.workflow.expr.WfExpression88659
while(auditEvents.hasNext())
^
/ptc/Windchill_101/Windchill/tmp/WfExpression88659.java:41: cannot find symbol
symbol : variable auditEvents
location: class wt.workflow.expr.WfExpression88659
wt.workflow.engine.WfVotingEventAudit audit = (wt.workflow.engine.WfVotingEventAudit)auditEvents.next();
Then I tried to declare auditEvents with the following code
Iterator auditEvents = auditCol.persistableIterator();
This throws an error about unknown Iterator class.
Regards,
Gautham
You're right. That detail was not shared.
Yogesh Bagul, can you please mention how you instantiated/populated auditEvents variable?
My apologies, I missed following line in the copy-pasted code.
java.util.Iterator auditEvents = auditCol.persistableIterator();
So the complete code should look like below.
wt.fc.collections.WTArrayList auditCol = (wt.fc.collections.WTArrayList) wt.workflow.engine.WfEngineHelper.service.getVotingEvents((wt.workflow.engine.WfProcess)self.getObject(), null, null, null);
java.util.Iterator auditEvents = auditCol.persistableIterator();
while( auditEvents.hasNext())
{
wt.workflow.engine.WfVotingEventAudit audit = (wt.workflow.engine.WfVotingEventAudit)auditEvents.next();
System.out.println("***Transition Expression: User vote = " + audit.getEventList());
System.out.println("***Transition Expression: User comment = " + audit.getUserComment());
comments += audit.getUserComment();
System.out.println("***Transition Expression: Complete Time = " + audit.getPersistInfo().getCreateStamp());
}
System.out.println("comments = " + comments);
Dear Yogesh,
Many thanks for your reply. That works.
Regards,
Gautham
Then I tried to declare auditEvents with the following code
Iterator auditEvents = auditCol.persistableIterator();
This throws an error about unknown Iterator class.
If you are entering this code into a workflow component then you need to fully most types. In this case you need to fully qualify java.util.Iterator like this:
java.util.Iterator auditEvents = auditCol.persistableIterator();
Dear Randy,
Many thanks for your reply. That indeed was the mistake.
two questions:
A) Can this code go on the Complete transition of a workflow Activity instead of in a separate expression robot?
B) What happens if there are multiple Users on a single Activity and each makes comments? It appears that they will be handled because an array is being used but not sure.. ( wt.fc.collections.WTArrayList)
If you need to use the code in a task transition you need to modify first part of function self.getObject()
You should change following line from
wt.fc.collections.WTArrayList auditCol = (wt.fc.collections.WTArrayList) wt.workflow.engine.WfEngineHelper.service.getVotingEvents((wt.workflow.engine.WfProcess)self.getObject(), null, null, null);
To
wt.fc.collections.WTArrayList auditCol = (wt.fc.collections.WTArrayList) wt.workflow.engine.WfEngineHelper.service.getVotingEvents((wt.workflow.engine.WfProcess)((wt.workflow.work.WfAssignedActivity)self.getObject()).getParentProcess(), null, null, null);
If there are multiple comments all ale added to the comment parameter as aditional string.