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 update issue Description field using Custom Listener from ScriptRunner? Edited

I have a Custom Listener from ScriptRunner for the "Work Started on Issue" event implemented like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


def im = ComponentAccessor.getIssueManager();
def i = event.issue
def userManager = ComponentAccessor.getUserManager();
def issueToChange = im.getIssueObject(i.id)
def user = userManager.getUserByName(currentUser.name)

def iType = i.issueType.name

if(iType == "Imputation"){
issueToChange.setDescription("hmm")
im.updateIssue(user, issueToChange, EventDispatchOption.DO_NOT_DISPATCH, false)
}

The script runs without an error when issue is set to the "in Progress" state.

In the History tab for the issue there is a record of the change made on the Description field:

Capture.PNG

But the Description field it self is empty!

Any ideas?

(It is on a local JIRA server installation version 7.8.0)

Thanks,

Birgir

 

3 answers

That's odd,

Can you also try editing issue 

IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters(); 
issueInputParameters.setDescription("I am a new description");
UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, i.id, issueInputParameters);
if (updateValidationResult.isValid()) {
IssueResult updateResult = issueService.update(user, updateValidationResult);
if (!updateResult.isValid()) {
// Do something
}
}

as described here

Thanks for the suggestion. I did as you proposed but the results are the same.

I also tried to update the Summary field to see if this had something to do with the Description field, but that didn't update either.

 

Capture.PNG 

Did you check your Jira index? Can there be any corruption?

Yes I checked and it all looks fine.

Sorry that I could not help. I was just curious if you've found out the root cause.

No I still haven´t figured this out :-)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

933 views 8 25
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