Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Enter the Console


Console display


Code examples

① Get currentUser

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

② Get issue information

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

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

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);

  • No labels