I'd like to write a Jira expression for use in a validator that checks if any of the following are true:
If any of these are true, the validator should allow the transition to happen. This is on the create transition in particular, so the issue should be created.
I've tried:
issue.customfield_10869.groups.includes('Account Managers') But get an error "Unrecognized property of `issue.customfield_10869.groups`: "includes""
I'm trying to create the validator using Scriptrunner.
Thanks!
I think it's because issue.customfield_10869 return a Map not a user Object.
You need to get the User object from the accountID property in the Map.
Something like
let userPickerValue = issue?.customfield_10869 != null
? new User(issue?.customfield_10869?.accountId)
: null;
Then you can do userPickerValue.groups
Regards
Thanks so much Florian - that really helped.
This is what I ended up with, which worked:
let userPickerValue = issue?.customfield_10869 != null
? new User(issue?.customfield_10869?.accountId)
: null;
return userPickerValue.groups.includes('X') || userPickerValue.groups.includes('Y') ||
user.groups.includes('X') || user.groups.includes('Y')
Thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would suggest taking a look at the ScriptRunner Migration Suite . It has a built-in AI and is very helpful with workflow expressions for Validators and Conditions.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram - that was my first port of call. Unfortunately it didn't help - from memory I think it only solved the "user performing the transition is in user group X" part, and couldn't help me work out the user picker group membership in the way that Florian did in the other reply.
Thanks for replying though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_, if you're part of a Marketplace App team, we would like to ask you to follow the steps outlined here to get an 'Atlassian Partner' lozenge for your profile and that you also include text in your comment stating you work for the company that built the app, per our Partner Rules of Engagement.
Thanks!
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.