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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Setup participant activity

ptc-4803475
1-Newbie

Setup participant activity

Hi

My problem is-

I have a setup participant activity.there are three roles for which i have to assign participants .For eg. if i assign participant for role A and role B.But if i dont assign anyone for role c.The task is going to the creator .i dont want that if no person is assigned to a role.I dont want it to go to anyone.How should i go about it??

13 REPLIES 13

Hello

you can add this code in the "complete transition" of your SetUp participant task, or in a conditionnal robot just behind

wt.workflow.engine.WfProcess wfprocess = ((wt.workflow.work.WfAssignedActivity)self.getObject()).getParentProcess();

java.util.Enumeration pinwf = wfprocess.getPrincipals(wt.project.Role.toRole("MY_ROLE_TO_TEST"));

int count = 0;

while (pinwf.hasMoreElements())

{

count = count+1;

pinwf.nextElement();

}

if count==0 no person have been slelected for this role ... so you can route your workflow differently

regards

Gregory

Thanks a lot mr.gregory...Iam getting the role for which there is no participant but how can i stop the task from going to anyone..

You can set the "count" as a global workflow variable.

And then after your setup participant task, put a conditionnal robot.

If count = 1, route to the next task where the partipant is needed

If count=0, route to another way with no task for this participant

Gregory is saying to add the role/counter piece to the complete transition of your setup participants activity. Then, instead of connecting the setup participants directly to the next activity, which may or may not have all required roles populated, first connect it to a conditional, then optionally connect it to the next activity. With this method, if you have three roles, you'll need three conditionals and three activities. Get creative with the AND and OR connectors to make it work. - That's how I see it anyways.

Thanks 🙂

Hi all,

I know it's an oldish thread, but I didn't want to start a new one on the same subject.

Does anyone have a working example of this code inside a simple workflow? No matter how I try to implement it in WC10.1 M40, it doesn't want to work.

TIA

KD
5-Regular Member
5-Regular Member
(To:ptc-1047216)

HI Bob,

I tried to implement the solution with a littlle bit different approach.

I also have a document for it.

But i dont know how to how to upload a document.So uploaded the picture of the workflow.

It may help you.

Thanks And Regards,

Kaushik

ptc-1047216
1-Newbie
(To:KD)

Thanks, Kaushik - unfortunately it does help me a great deal!

The problem is that however I try to implement the code listed in this thread, whether by including it in WorkflowHelper or inside a conditional router, or inside a Complete Transition, I get the following error;

java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity

Nested exception is: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity

wt.util.WTException: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity

Nested exception is: java.lang.ClassCastException: wt.workflow.engine.WfProcess cannot be cast to wt.workflow.work.WfAssignedActivity

at wt.workflow.expr.WfExpression97382.execute_ROUTER_EXPRESSION_(WfExpression97382.java:23)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at wt.workflow.definer.WfExpression.invokeByReflectionWithTransaction(WfExpression.java:1204)

at wt.workflow.definer.WfExpression.executeRouter(WfExpression.java:1322)

at wt.workflow.definer.WfExpression.execute(WfExpression.java:416)

at wt.workflow.engine.WfConnector.evaluateRouterExpression(WfConnector.java:586)

at wt.workflow.engine.WfConnector.fire(WfConnector.java:350)

at wt.workflow.engine.WfConnector.fireInput(WfConnector.java:314)

at wt.workflow.engine.ActivityConnectorLink.receiveEvent(ActivityConnectorLink.java:143)

at wt.workflow.engine.StandardWfEngineService.propagateEvent(StandardWfEngineService.java:861)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at wt.queue.QueueEntry.execute(QueueEntry.java:232)

at wt.queue.QueueRunnable.run(QueueRunnable.java:186)

at java.util.concurrent.ThreadPoolExecutor$Worke

What is I'm missing, or doing wrong?

(None of this helped by the fact that I'm not a programmer!!!)


Bob.

KD
5-Regular Member
5-Regular Member
(To:ptc-1047216)

Hello Bob,

From the error message you posted here it seems its generated from a Conditional Router.i.e you put the code in a conditional router.

Now, "wt.workflow.engine.WfProcess wfprocess = ((wt.workflow.work.WfAssignedActivity)self.getObject()).getParentProcess();" this part of the code is really tricky.

If you write this part in complete transition then self means WfAssignedActivity as it is refering to the self variable name of the Activity.

But if you write the code in Conditional Robot or Expression Robot then it will refer to the global variable self which is WfProcess.So, this conflict may cause the Class cast exception.

Before casting you print the object using System.out.println(self.getObject()); Hope then you can resolve the type casting problem.

Regards,

Kaushik

ptc-1047216
1-Newbie
(To:KD)

Kaushik

I think I'll just have to admit to myself that I'm just not able to grasp the detail of this and give up!!!

Many thanks for you time!

Bob.

Bob, replace *.wfassignedactivity with *.wfprocess. Remove .getParentProcess(). Use correct package names (wt.workflow.whatever). Use correct capitalization. I'm replying from my phone, so copy/paste isn't working for me. Sorry I couldn't help you more.

MatthewKnight
4-Participant
(To:KD)

I just want to add a small reply to Kaushik's excellent response. The way I understand it is every piece of code in a workflow template gets compiled into a WfExpression class, which always has a "self" ObjectReference variable. Self.getObject() can return a different type of object based on the context of the call, so it's up to you to cast it appropriately. Technically, I don't think you can cast anything to a WfAssignedActivity while assigning it to a WfProcess. I think that was just a pseudo example to let you know what you can generally expect. When I'm not sure, I also go with Kaushik's println method, with one small difference. To account for overridden toStrings, I println(self.getObject().getClass ().getName()).

My bad on the incorrect cast comment. I'm on a mobile device and missed the getParentProcess call. Inner scrolling boxes for the lose. 🙂

Announcements


Top Tags