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

How to set jira issue type with script runner

Hi,

I am using script runner to create a new issue, need to set its type to "mytype"...but I am stuck.

Any help?

Thank you!

2 answers

1 accepted

yes, I  do it. but .... The issue type does change, but the workflow seems to only be partially migrated. The View Workflow button on the issue does show the new workflow, but no workflow buttons are available.

I need to do this too.  The link above does not work for me.  If use this code, it IS getting the newIssueType, but is not able to change the issue type:

{code}
import com.atlassian.jira.component.ComponentAccessor

def newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(issue.projectObject).find{it.name=="Information Only Change"}
if (newIssueType) issue.setIssueObject(newIssueType)

{code}
Error:
No signature of method: com.atlassian.jira.issue.IssueImpl.setIssueObject() is applicable for argument types: (com.atlassian.jira.issue.issuetype.IssueTypeImpl) values: [com.atlassian.jira.issue.issuetype.IssueTypeImpl@e09d6de4] Possible solutions: getIssueObject(org.ofbiz.core.entity.GenericValue), setIssueTypeObject(com.atlassian.jira.issue.issuetype.IssueType

You have to use MutableIssue class, not Issue.
Issue for getting info only, MutableIssue for both: getting and changing your issue.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

// get issue by key for example
MutableIssue
 issue = ComponentAccessor.getIssueManager().getIssueObject('ABC-123')

def
 newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(issue.getProjectObject()).find{it.getId() == "3"}
issue.setIssueTypeObject(newIssueType)

// update issue for saving changes
ComponentAccessor.issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false)

 

Suggest an answer

Log in or Sign up to answer
TAGS

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