Hello,
I wanted to validate user's group while creating issue. We have a field GROUP which is in user property. I wanted to allow create issue permission to one particular group of users.
I have a user property named GROUP with values G1,G2,G3,G4. Only G1 users can create issues. I wanted to restrict create issue access to other GROUP users.
I tried to add validator in Create transition using following script but no luck :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.UserPropertyManager
UserPropertyManager userPropertyManager = ComponentAccessor.getUserPropertyManager()
if (issue.reporter) {
userPropertyManager.getPropertySet("GROUP") != 'G1'
}
How can I achieve this?
Thanks in advance.
Why are you doing this? You can achieve the same far more cleanly and better with simple group memberships.
Hello,
Could you please precise?
FYI we don't have any 'User GROUP'. These user categories are driven from external ED using scripts. This user details (G1,G2,G3,G4) are present only under 'User Properties' and yes also in Custom fields (using nfeed) but those values filled post creation of issue.
But I need to validate while creating issue. If reporter is not in G1 then they cannot raise issues.
User Property Key : GROUP
Values : G1,G2,G3 and G4
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't understand why you are doing it this way. It's clumsy, frail and not transparent. You're doing a lot of work to do something JIRA does off-the-shelf in a really simple way.
Put your users into groups. Use the permissions to say "only users in group 1 can create issues".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have nearly 20k users. All users belongs to these categories. So it is difficult to find them and group. Users will get added on a daily basis. it is difficult to find them everyday and add them in group.
So i found using 'User Property' value is simplest.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's absolutely not the simplest way to do it.
You still have to identify your users and then set a property to do it. Why not simply set a group instead?
Also, this makes me suspect that you're setting the user properties in a way that is wrong, as there's no easy way to do it reliably, and if you were doing it the reliable way, you would not need help with this question!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know I'm not being "helpful" here, but your approach to this is pretty much broken, and it is always worth questioning it when we see that.
If you insist on persuing it badly though, then the problem is in your line
getPropertySet("GROUP") != 'G1'
This "get" does not return a simple string, it returns a whole property set for the user's properties. Even if you have only set one, it's still the whole set that comes back. This is documented at https://developer.atlassian.com/static/javadoc/opensymphony-propertyset/1.5/reference/com/opensymphony/module/propertyset/PropertySet.html and you'll see you need to find your property within that and pull it out to be compared.
But that's what you should have used when you are setting the properties (which is why I'm worried about how you are setting them)
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.