I have a case where I need to hide the "Create" button in just ONE project. Using script fragments, I was able to hide the clone and move menu items without fail BUT when I try the same thing with the "Create" button, JIRA constantly throws the following in the log file. It WORKS the error shows every couple of seconds
[c.o.scriptrunner.fragments.JiraScriptCondition] Script condition failed: java.lang.NullPointerException
I select the "com.atlassian.jira.jira-header-plugin:create-issue" module key to hide. The code I put in is:
import com.atlassian.jira.component.ComponentAccessor
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def allowedUser = ComponentAccessor.groupManager.getGroupNamesForUser(currentUser).contains("AllowedGroup")
jiraHelper.project?.key != "TARGETPROJECT" || allowedUser
So... (to my tiny mind and appears to function as such), IF the project is not "PROJECT" OR the current user is allowed (even if IN "PROJECT"), the Create button shows. Conversely, if I am IN "PROJECT" and I AM an allowed user, it will show. If I am in PROJECT and NOT an allowed user, it does not show.
To validate the logic, I put it in the Script console with a small change to test with as such (where I am an "allowed user"):
import com.atlassian.jira.component.ComponentAccessor
def project = "TARGETPROJECT"
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def allowedUser = ComponentAccessor.groupManager.getGroupNamesForUser(currentUser).contains("AllowedGroup")
project != "TARGETPROJECT" || allowedUser
The above throws no errors and only the expected "true" or "false" depending on whether I am an "allowed user" depending on which group I set
Anyone have any clues? This is driving me mad (a short drive to be sure)