I have a use case where the project owners want a "disclaimer" message field displayed on issue create to all Jira users aside from those in their Jira user group. It correctly, doesn't appear if one is in the group that doesn't want to see it. However, the disclaimer will display correctly only if one lands directly on an issue create screen for that particular project. Also, if one changes the issue type, or changes to another project and back to the one that wants the disclaimer, it won't reappear.
The behavior is below. I have a log.debug in there that throws the true/false statement in the logfile. It is correctly evaluating whether the disclaimer field should display or not but I still get the "not" displayed when I really want it to as described above.
Any ideas?
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.component.ComponentAccessor
def disclaimWarn = getFieldById("customfield_17206")
def aGroup = ComponentAccessor.groupManager.getGroup("groupBeingChecked")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()
def inGroup = ComponentAccessor.groupManager.getUserNamesInGroup(aGroup).contains(currentUser)
log.debug "${inGroup}"
if (inGroup) {disclaimWarn.setHidden(true)}
else {disclaimWarn.setHidden(false)}
Hello,
do you have it as an initializer or as a field script? I feel like 2nd option should work
Also, better way to check if user is in group is by using this method:
def inGroup = groupManager.isUserInGroup(ApplicationUser user, String groupName)
Hi @Ilya Turov ,
I should've mentioned; I have this in as a server side script. I do not however have this in as an initializer. Perhaps I should put the same script in both places?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dang... thought you might have been onto something. I put that same script (albeit without your very good suggestion) in the initializer and... same result. The validation still validates correctly but the results cited above still are present.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, I didn't have access to jira yesterday, but now I've got to it and tested.
Dunno what's really happening in your behaviour, but for me it worked.
Do you per chance have this field hidden in a field configuration? Because I believe behaviour won't override it, that's my only educated guess.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.