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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Programmatically find latest votes for user on change task

TWil24
7-Bedrock

Programmatically find latest votes for user on change task

Is there anyway to pull the latest assignment from a user on a particular assignment using java? Currently, I'm working on a report that displays the votes of each user that has been assigned an assignment. However, when it get's re-subrouted, the code I have currently does not know which vote was the latest so it will display "old" votes.

 

I'm currently working on code that attempts to find the latest timestamp of an assignment's creation and use it but even that's becoming messy.

9 REPLIES 9
avillanueva
22-Sapphire II
(To:TWil24)

I did this slightly differently using eSignatures. Each time I loop through, signature history was cleared so there was only 1 set to find.

QueryResult result=PersistenceHelper.manager.navigate(ecn,SignatureLink.SIGNATURE_ROLE,SignatureLink.class,false);

This was against a Change Notice. If you are using the esignature check box, those capture votes as well

SignatureLink link=null;
while(result.hasMoreElements()) {
link=(SignatureLink)result.nextElement();

link.getVote().

You should be able to get user, role and date from this object. I hope this helps.

Hi avillanueva,

Hi took Affected Objects from getChangeablesBefore(); but now I am facing an issue to get On Order, Disposition comment Work in progress and Finished.

To take get these values I am using AffectedActivityData affectedActivityData = (AffectedActivityData) Object;

but its not working.

Please help .

_1647_0-1723477069894.png

 

avillanueva
22-Sapphire II
(To:@_1647)

You asked about votes. This looks like a different question. Might want to start a new thread.

Could you please help me to get values for this

   On Order, Disposition comment,  Work in progress and Finished  programmatically.

avillanueva
22-Sapphire II
(To:@_1647)

QueryResult aResult=ChangeHelper2.service.getChangeablesBefore(ca,false);
Enumeration enumeration2=aResult.reset();
WTObject object=(WTObject)enumeration2.nextElement();
if (object instanceof AffectedActivityData)
{
AffectedActivityData aad=(AffectedActivityData)object;

from there you can get what you need:

onOrder=aad.getOnOrderDisposition().getDisplay();
wip=aad.getInventoryDisposition().getDisplay();
finished=aad.getFinishedDisposition().getDisplay();
dispositionComments=aad.getDispositionComments();

I am executing the same but from code it's not getting triggered I don't why and not getting printed 

avillanueva
22-Sapphire II
(To:@_1647)

@_1647 , I would start a new thread. Your questions are not related to the original post. 

Ok

HelesicPetr
22-Sapphire I
(To:TWil24)

Hello @TWil24 ,

 

I needed to get comments similar way how you need the votes with users.

I wrote code for worflow transiction Start where I needed to show to user previous comments of users who wanted more information

I didn't sort the results because they follow that what is first in iterator is last 

 

Code


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);
System.out.println("***Transition Expression: Audit = " + auditCol.toString());
Integer comentnumber=0;
java.util.Iterator auditEvents0 = auditCol.persistableIterator();
//here I need to know how many times the Clarify transaction is done.
while( auditEvents0.hasNext())
{
wt.workflow.engine.WfVotingEventAudit audit1 = (wt.workflow.engine.WfVotingEventAudit)auditEvents0.next();
if(audit1.getEventList().toString().equalsIgnoreCase("[Clarify]")) // string name of transation name
{
comentnumber = comentnumber +1;
}
}
java.util.Iterator auditEvents = auditCol.persistableIterator();
String comments = "";
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());
if(audit.getEventList().toString().equalsIgnoreCase("[Clarify]")){
comments += comentnumber+ ". comment - " + audit.getUserRef().getName() + ": " + audit.getUserComment() + "\n"; // here you can use getEventList()
comentnumber=comentnumber-1;
System.out.println("***Transition Expression: Complete Time = " + audit.getPersistInfo().getCreateStamp());
}
}
System.out.println("comments = " + comments);
String special_instructions1 = comments;

 results in a task page in instructions:

HelesicPetr_0-1641992582425.png

HelesicPetr_1-1641992872417.png

 

Top Tags