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

ScriptRunner update summary from another issue Edited

I need help.

 

Could someone help me write a script that changes the summary of another issue.

I have in a customfield the KEY of this issue that I want to change.

 


import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.component.ComponentAccessor;


def id_vaga = customFieldManager.getCustomFieldObject("customfield_16057")
def key_value = issue.getCustomFieldValue(id_vaga).toString()


def issueManager = ComponentAccessor.getIssueManager()
def issue1 = issueManager.getIssueObject("${key_value}")

issue1.setSummary("XYZ")

 

2 answers

1 accepted

1 vote
Answer accepted

It depends where you add your post function. You could try also this one

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor

def id_vaga = customFieldManager.getCustomFieldObject("customfield_16057")
def key_value = issue.getCustomFieldValue(id_vaga).toString()

IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject(key_value);
issue.setSummary("XYZ");
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)

tks @Alexey Matveev _cPrime_ for your response!

 

But I'm getting the same error as I reported in the comment above.

It is a static error. If you run the script, the script would work. Or You could write like this:

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor

def id_vaga = customFieldManager.getCustomFieldObject("customfield_16057")
def key_value = issue.getCustomFieldValue(id_vaga).toString()

IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject(key_value) as MutableIssue;
issue.setSummary("XYZ");
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)

I solved the problem by adding the lines below:

import com.atlassian.jira.issue.MutableIssue

def customFieldManager = ComponentAccessor.getCustomFieldManager()

But this signaling me another mistake

 image.png

image.png

 

Even though I save and trying to execute the transition, the summary of the other issue is not changed (and this error appears in the log)

 

2018-05-30 08:54:46,492 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2018-05-30 08:54:46,492 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: RH-118, actionId: 111, file: <inline script> groovy.lang.MissingPropertyException: No such property: EventDispatchOption for class: Script1725 at Script1725.run(Script1725.groovy:15)

 

Try like this:

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def id_vaga = customFieldManager.getCustomFieldObject("customfield_16057")
def key_value = issue.getCustomFieldValue(id_vaga).toString()

IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject(key_value) as MutableIssue;
issue.setSummary("XYZ");
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
Like Gandhari Soumya likes this

IT WORKS !!!!

VERY VERY THANKFUL!

Try this one

import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor

def id_vaga = customFieldManager.getCustomFieldObject("customfield_16057")
def key_value = issue.getCustomFieldValue(id_vaga).toString()

IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject(key_value);
issue.setSummary("XYZ");


Tks @Tuncay Senturk _Snapbytes_ for your response!

 

I'm getting this error message when trying to save the script.

image.pngJIRA 7.1.7
I want to use this script in post function.

Add the import statement,

 

import com.atlassian.jira.issue.MutableIssue;

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