Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Enter the Console

Image RemovedImage Added
Table of Contents

Console display


Code examples

① Get currentUser

Code Block
import com.atlassian.jira.component.ComponentAccessor
/**
 * get currentUser
 */
ComponentAccessor.jiraAuthenticationContext.loggedInUser

② Get issue information

Code Block
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

/**
 * Get issue information
 */
def issue = ComponentAccessor.issueManager.getIssueObject("WOR-1") as Issue
issue?.summary

③ Gets the value of the custom field of the issue

Code Block
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField

/**
 * Gets the value of the specified custom field of the issue
 */
def customField = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_10200") as CustomField
def issue = ComponentAccessor.issueManager.getIssueObject("WOR-1") as Issue;
issue?.getCustomFieldValue(customField);


④ create issue

Code Block
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser

/**
 * create issue
 */
def mutableIssue = ComponentAccessor.issueFactory.getIssue();
def issue = ComponentAccessor.issueManager.getIssueObject("WOR-1") as Issue;
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser as ApplicationUser
mutableIssue.setSummary("summary test")
mutableIssue.setProjectObject(issue?.projectObject)
mutableIssue.setIssueType(issue?.getIssueType())
mutableIssue.setReporter(currentUser);
ComponentAccessor.issueManager.createIssueObject(currentUser,mutableIssue);