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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Web-item condition getIssue()

Hi,

I have a plugin(web-item under "More Actions" in Issuescreen) that should be only displayed if the displayed Issue is of issuetype "Risk" or "Issue". I wrote a condition for it, but I don't know how to get the Issue that I'm looking at. Here the Code:

import java.util.Collection;

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.fields.config.manager.IssueTypeSchemeManager;
import com.atlassian.jira.issue.issuetype.IssueType;
import com.atlassian.jira.plugin.webfragment.conditions.AbstractJiraCondition;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.jira.project.Project;

public class RiskIssueCondition extends AbstractJiraCondition {

    protected final IssueTypeSchemeManager issueTypeSchemeManager;

    protected final IssueManager issueManager;
    
// need the issue to check if it's of issuetype "Risk" or "Issue" Issue issue = issueManager.getIssueObject(); public RiskIssueCondition (IssueTypeSchemeManager issueTypeSchemeManager, IssueManager issueManager){ this.issueTypeSchemeManager = issueTypeSchemeManager; this.issueManager = issueManager; } @Override public boolean shouldDisplay(User user, JiraHelper jiraHelper) { return (getIssueTypeId(issue.getProjectObject())); } private boolean getIssueTypeId(Project project) { Collection<IssueType> issueTypesForProject = issueTypeSchemeManager.getIssueTypesForProject(project); for (IssueType issueType : issueTypesForProject) { if (issueType.getName().equals("Risk") || issueType.getName().equals("Issue")) { return true; } } return false; } }

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted

Try

Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");


Worked. Thanks.

Here the working condition:

public class RiskIssueCondition extends AbstractJiraCondition {

	@Override
	public boolean shouldDisplay(User user, JiraHelper jiraHelper) {
		
		Issue currentIssue = (Issue) jiraHelper.getContextParams().get("issue");
		
		return (currentIssue.getIssueTypeObject().getName().equals("Risk") || currentIssue.getIssueTypeObject().getName().equals("Issue"));
	}
}

could you please past the complate code...i have followed the step but it not working at all...

protected final IssueTypeSchemeManager issueTypeSchemeManager;

    protected final IssueManager issueManager;

this two statement asking for initilization or remove final.

Issue issue = issueManager.getIssueObject();

this line asking for pass object to .getIssueObject

and since there is no value in

issueManager

it will throw nullpointer exception 

so could you plz past right code format i have tryed every angle but result is zero.

TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

640 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you