Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,410,348
Community Members
 
Community Events
169
Community Groups

Post Function for setting security level removes the transition permission from the user

Hi,

I have written a groovy script to set different security levels to issue based on a customfield value. This code actually changes the security level but the it hides the transition/removes the permission to execute the transition from the users .

I want to set the issue security level and the transition also should be accessible for the users who have permission for that. 

Please check my code and suggest

My code goes here:

import com.atlassian.jira.ComponentManager; 
import com.atlassian.jira.ManagerFactory ;
import com.atlassian.jira.issue.security.IssueSecurityLevelManager;
import com.atlassian.jira.issue.security.IssueSecuritySchemeManager; 
import com.atlassian.jira.issue.IssueImpl;
import org.apache.log4j.Category ;
import com.opensymphony.workflow.loader.ActionDescriptor;
import com.atlassian.jira.issue.MutableIssue;
import org.ofbiz.core.entity.GenericValue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.bc.project.component.ProjectComponent;
import com.atlassian.jira.bc.project.component.ProjectComponentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueFactory;


ComponentManager componentManager = ComponentManager.getInstance() ;
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def plant = customFieldManager.getCustomFieldObjectByName("Plant");
def plantValue = issue.getCustomFieldValue(plant) as String;

if(issue.issueTypeObject.name == "Plants")
{
log.debug("**********Received plant value*********");
if(plantValue.contains("Rohtak"))
{
log.debug("******************Logging1******************")
issue.setSecurityLevelId(12403) 
}
else if(plantValue.contains("Patancheru")) 
{
log.debug("******************Logging2******************")
issue.setSecurityLevelId(12405) 
}
else if(plantValue.contains("Ankleshwar")) 
{
log.debug("******************Logging3******************")
issue.setSecurityLevelId(12404) 
}
else if(plantValue.contains("Kasna")) 
{
log.debug("******************Logging4******************")
issue.setSecurityLevelId(12406) 
}
else
{
log.debug("******************Logging5******************")
issue.setSecurityLevelId(12401)
}
}
if(issue.issueTypeObject.name == "Non-Plants")
{
log.debug("******************Logging6******************")
issue.setSecurityLevelId(12402)
}

 

1 comment

The setting of the security level is what is removing the user's permission to act on the issue.

Thanks Nic for your reply.

The users are in the security level and have the transition permission also. then why the change in security level restricts the transition?I have tested it by adding Admin Id in a security level and created an issue. The same happens to me.

Comment

Log in or Sign up to comment