cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

workflow activity - pull comments into Special Instructions

Highlighted
Guest

workflow activity - pull comments into Special Instructions

We use the comments section to communicate within the workflows activities. Users have to hunt over to the Process tab to see these instructions.
I would like to take the Comment in the activity and put it into the workflow variable special_instructions so that it shows on the task details.
Has anyone the code?

Thanks!
Vaughn
13 REPLIES 13
Highlighted

RE: workflow activity - pull comments into Special Instructions

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);



Highlighted

RE: workflow activity - pull comments into Special Instructions

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


IntelliServ provides broadband networking and along-string
evaluation services for high-definit...




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);



Highlighted

Re: workflow activity - pull comments into Special Instructions

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

Highlighted

Re: workflow activity - pull comments into Special Instructions

Gautham Prashanth Kandan‌, what is the error you recieve?

Highlighted

Re: workflow activity - pull comments into Special Instructions

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

Highlighted

Re: workflow activity - pull comments into Special Instructions

You're right.  That detail was not shared.

Yogesh Bagul‌, can you please mention how you instantiated/populated auditEvents variable?

Highlighted

Re: workflow activity - pull comments into Special Instructions

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);

Highlighted

Re: workflow activity - pull comments into Special Instructions

Dear Yogesh,

Many thanks for your reply. That works.

Regards,

Gautham

Highlighted

Re: workflow activity - pull comments into Special Instructions

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();

Highlighted

Re: workflow activity - pull comments into Special Instructions

Dear Randy,

Many thanks for your reply. That indeed was the mistake.

Highlighted

Re: workflow activity - pull comments into Special Instructions

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)

Highlighted

Re: workflow activity - pull comments into Special Instructions

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.

Highlighted

Re: RE: workflow activity - pull comments into Special Instructions

I tested the code in the task complete transition expresion and result is empty because the information of the completed task is not writen in a database that moment. I would advise to use the expresion code in start up of following tasks or in expresion robot.

Announcements