Forums

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

JMWE Validator - Verify that the Assignee is not being assigned as an approver (custom field)

Tyler Stephens
Contributor
February 8, 2022

JMWE Validator - Verify that the Assignee is not being assigned as an approver (custom field). 

To transfer to a following status, user is required to assign user's approver roles, user is not allowed to be in any of these roles. 

Any advice?

1 answer

1 accepted

0 votes
Answer accepted
Tessa Tuteleers
Community Champion
February 8, 2022

Hi @Tyler Stephens , 

You can write scripted validator using JMWE for this: 

you first check if the approvers field has a field, and then that the assignee is not in the value(s) of that same field. 

The JMWE editor actually helps you a lot, so please try and play around with it to check for yourself. 

For me, this would look something look this: 

-> customfield_10003 is my 'approvers field', you can click on "issue fields" in the jmwe app and find your own id for the field

-> i first check if the field is not null with !! 

-> I then check the value(s) in the field, and match the id of all values to the id of the assignee, it should not match to any

!!issue.customfield_10003 && !issue.customfield_10003.some(it => it.accountId == issue.assignee.accountId)

 

Hope this helps, 

- Tessa

Tyler Stephens
Contributor
February 8, 2022

Hi Tessa,

I received the following error: 

Evaluation failed: "issue.customfield_13743.some(it => it.accountId == issue.assignee.accountId)" - issue.customfield_13743.some (null) is not a function

David Fischer
Community Champion
February 8, 2022

Hi @Tyler Stephens ,

that means that customfield_13743 is empty. In Tessa's example, there was this in front of the expression: 

!!issue.customfield_10003 && 

You seem to have omitted it. Your expression should be:

!!issue.customfield_13743 && issue.customfield_13743.some(it => it.accountId == issue.assignee.accountId)
Tyler Stephens
Contributor
February 9, 2022

Hi @David Fischer

I used the full expression Tessa provided. Could the expression be affected due to the field being in a transition screen? My goal is for the validator to verify the field on this transition screen (customfield_13743 != the assignee). 

David Fischer
Community Champion
February 9, 2022

@Tyler Stephens are you sure customfield_13743 is a multi-user picker field? If it is instead a single user picker field, the code should be:

!!issue.customfield_13743 && issue.customfield_13743.accountId == issue.assignee.accountId
Tyler Stephens
Contributor
February 9, 2022

@David Fischer 

Correct, it is a single user picker field. I tested with the above code, I am assignee and the approver and it let me proceed without validation being triggered. 

David Fischer
Community Champion
February 9, 2022

I looked at your JMWE logs, and I believe you want to prevent the current user from being the validator. In that case, the script should be:

!issue.customfield_13743 || issue.customfield_13743.accountId != user.accountId
Like Tyler Stephens likes this
Tyler Stephens
Contributor
February 9, 2022

@David Fischer That worked! Thank you, appreciate you and @Tessa Tuteleers help on the situation. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events