hi i want to show a field which can only seen by user belong to admin group , except that all other user can not see that field ,that will be hiddden for them.
can anyone help me this?
my admi group is "jira-administrators",
i want to check like that the person who belong to the the above group can be able to see that else, it will be hidden.
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.security.roles.ProjectRoleManager
def log = Logger.getLogger("scriptRoots.src.main.defaultRoot.behaviors")
log.setLevel(Level.DEBUG)
def startDateFlag=false;
def issue = underlyingIssue
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager)
//def groupA = ComponentAccessor.groupManager.getGroup("jira-administrators")
//ComponentAccessor.groupManager.getUserNamesInGroup(groupA).contains("jk77026")
//def role = projectRoleManager.getProjectRole("jira-administrators")
//def role = projectRoleManager.getProjectRole("jira-administrators")
//return projectRoleManager.isUserInProjectRole(currentUser, role, issue.getProjectObject())
/* Check if Project Types value is Multi-Release */
def projectTypeValue = getFieldByName("Project Type").getValue() as String
if(projectTypeValue != null) {
/* Compare the two dates and set the startDateFlag */
if(projectTypeValue == "Agile Major"){
if(getFieldByName("Project Start Date").getValue() as String != ''){
Date startDateValue = getFieldByName("Project Start Date").getValue() as Date
Integer startDate = startDateValue.format('yyyyMMdd') as Integer
Integer cutOffDate = Date.parse("yyyy-MM-dd hh:mm:ss", "2019-02-24 00:00:00").format("yyyyMMdd") as Integer
if(startDate>cutOffDate) startDateFlag=true;
else startDateFlag=false;
}
}
if(projectTypeValue == "Agile Multi Release" || (projectTypeValue == "Agile Major" && startDateFlag == true)) {
if(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()=='jk77026'){
getFieldByName("Impacted Application/s").setHidden(false);}
else{
getFieldByName("Impacted Application/s").setHidden(true);
}
} else if(projectTypeValue != "Waterfall") {
if(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getName()=='jk77026'){
getFieldByName("Impacted Application/s").setHidden(false);}
else{
getFieldByName("Impacted Application/s").setHidden(true);
}
}
}
any help will be appreciated.
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.