Forums

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

JMWE Scripted (Groovy) Condition

Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2021

Hi Community,

I have a question, can a condition be made that one user cannot close a ticket if there has ever been an assaignee on the ticket?

This would achieve the principle of 4 eyes for security problems in our Workflow. Can anyone help me here?

 

Best regards

Jurica

2 answers

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
April 6, 2021

Hi @Jurica Petricevic ,

using JMWE, you could use a Scripted (Groovy) Condition with this script:

issue.getFieldHistory("assignee").size() > 0

This will check if the Assignee field was ever modified (which is equivalent to saying it was assigned to someone at some point) 

Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2021

Yes, but in our case more users can be exchanged at one ticket. None of them can close the ticket.

No one who was involved in the solution should be able to close the ticket.

David Fischer
Community Champion
April 7, 2021

So what you mean is that you don't want a user to close a ticket if the same user was ever were assigned to the ticket before? 

If so, this is the script you want:

!issue.getFieldHistory("assignee")?.find{it.to == currentUser.key}
Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 7, 2021

Hi David, I'm not sure why but it doesn't work? Is it still Scripted (Groovy) Condition?

David Fischer
Community Champion
April 7, 2021

Yes. 
What doing you mean by "not working"?

Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 7, 2021

quite normally any user who is currently assignee  but also one who has been can close a ticket.

 

and i need this:

"So what you mean is that you don't want a user to close a ticket if the same user was ever were assigned to the ticket before? " exactly that.

David Fischer
Community Champion
April 8, 2021

So you created a Scripted (Groovy) Condition, put in the script I provided, published your workflow, and a user who is the current assignee or a past assignee can still see the transition?

I tested the same and it worked just fine.

Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 13, 2021

Forgive me David for being late. The request changed a little bit at the last meeting. The ticket should not be closed by anyone who worked on the last status. What does that mean? The one who clicked the transition "test" cant close the ticket. Do you have any idea how to solve this?

 

Only the one that said am ready for test, transition called "Test" shouldnt be able to "Close".

David Fischer
Community Champion
April 13, 2021

Hi @Jurica Petricevic ,

there are multiple ways to achieve this. You could "memorize" the user who triggered the "Test" transition in a Single User Picker custom field, using a Set Field Value post-function. Then you could simply make sure the current user is different from that memorized user:

currentUser != issue.get("Tester")

If you don't want to create a new custom field for that, you could use this condition directly:

!ComponentAccessor.changeHistoryManager.getAllChangeItems(issue)
.any{it.field=="status" && it.to == "In Test" && it.user == currentUser.key}

Note that "In Test" in the script represents the Status name of the destination status of the Test transition, not the transition name which is not memorized by Jira. 

Like Jurica Petricevic likes this
Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 13, 2021

The perfect solution. Thanks a lot David.

0 votes
Juan Manuel Ibarra
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2021

In this case you should have the history of those assigned in this field which is quite complicated. What you could do is have a multiple user type field (It can be hidden from the user) and every time the assign is changed, the user joins that field.

This will then allow you to compare the list of users of the field with the one that

Jurica Petricevic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2021

I need 100 new fields in that case because so many users change on one ticket. Also, I'm not sure how to check all 100 and allow someone to close / test the solution.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events