Make Script Task Wait

cancel
Showing results for 
Search instead for 
Did you mean: 
ali_malik
Member II

Make Script Task Wait

Hi,

I have an activiti workflow in which I go from User Task1 -> Groovy Script (Script Task) -> User Task2. 

The question is I want to reach the User Task2 only when I know the Groovy Script has completed.

The groovy script hasn't completed and the user task 2 gets activated. Maybe I need to set some configuration variable so that the page needs to be refreshed before Task2 is handled?

I have checked they're all Synchronous, but still User Task2 pops up all of a sudden. Is script task supposed to be this way?

Thank you

3 Replies
thuynh
Established Member II

Re: Make Script Task Wait

Hi Ali Malik ,

Could you explain your model/use case a bit more please? Essentially, what are you trying to model? 

Also for your script task, what is it doing? Can you share your script code? 

I have checked they're all Synchronous, but still User Task2 pops up all of a sudden. Is script task supposed to be this way?

Process instance execution reaches User Task 2 because the script task has been completed. This is expected. Again, please share a clearer description of what you're trying to achieve. 

Thanks,

Thong Huynh

ali_malik
Member II

Re: Make Script Task Wait

Hi Thong Huynh‌,

In my use case, I have a user task, Let's call it User Task 1. There's a button called "Re-assign". If you press this button, it takes you to User Task 2. If you don't, the workflow changes, but that's fine. When you do get to User Task 2, you select a new user to re-assign that task. When you press Submit, a Groovy script is called. In that script, the current user is being removed from the role that can execute User Task 1, and the new user is added to that role. But as soon as the script is executed, current user again sees User Task 1 and the new user doesn't.

It seems like a concurrency issue, perhaps? Because when the current user sees User Task 1 again, and presses "Re-assign" again, the current user doesn't see the User Task 2, the new user now sees User Task 2.

Flow problem: New user should have seen User Task 1, and current user shouldn't have seen User Task 1 for the second time.

I hope I got my point across, thank you for your help!

thuynh
Established Member II

Re: Make Script Task Wait

Hi Ali Malik ,

Not quite. I'm still not understanding the bpmn model that you're trying to implement here. Are you implementing a 'Task Reassignment' workflow? Instead of listing out the steps of what you are doing, take a step back and explain the higher goal of what you're trying to achieve. It is important to understand the goals and get the process modelling right before we can talk about deeper technical pieces. 

You stated the problem is that 

New user should have seen User Task 1, and current user shouldn't have seen User Task 1 for the second time.

This is not a good problem statement unless you can attach a unit test that we can run and see the issue. Without a unit test, it's difficult for anyone in this forum to help you. 

Please spend time to write up a unit test that demonstrates your issue so people here can help you resolve it.

How to write a unit test when creating an Activiti Jira issue | Small steps with big feet 

Hope this makes sense,

Thong