Hello,
I am trying to hide the "Create sub-task" button on a specific project, if the user performing the action (current user) is not in a specific user picker custom field.
What I have so far:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.Issue;
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def resp = customFieldManager.getCustomFieldObjectsByName("Responsible")
String username = issue.getCustomFieldValue(resp).name
ApplicationUser user = ComponentAccessor.getUserManager().getUserByName(username);
if (!issue.getProjectObject().getKey() == "ProjectA") { return true
}
else {
boolean condition = (issue.getProjectObject().getKey() == "ProjectA" && currentUser != user.name)
log.error("condition : " + condition)
condition
}
My problem is that it works for projectA (hides the sub-task create button from the "More" menu) if the current user is not the responsible, but for all other projects it is not showing the button anymore, like the if condition does not exist.
Please let me know your thoughts.
Thank you.