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?
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.