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:
But the Description field it self is empty!
Any ideas?
(It is on a local JIRA server installation version 7.8.0)
Thanks,
Birgir
Hello,
You can try this one.
I used it on my side and worked fine
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.user.ApplicationUser
import groovy.transform.Field
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
IssueEvent event = event as IssueEvent;
JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext();
ApplicationUser appUser = authContext.getLoggedInUser();
ComponentAccessor componentAccessor = new ComponentAccessor();
IssueManager issueManager = componentAccessor.getIssueManager();
MutableIssue issue = event.getIssue() as MutableIssue;
def issueIndexingService = componentAccessor.getComponent(IssueIndexingService);
String text = "hmm";
if(issue.getIssueType().name == "Imputation")
{
issue.setDescription(text);
issueManager.updateIssue(appUser, issue, EventDispatchOption.ISSUE_UPDATED, false);
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
issueIndexingService.reIndex(issueManager.getIssueObject(issue.id));
ImportUtils.setIndexIssues(wasIndexing);
}
I hope it helps.
Regards,
Luis
Did you check your Jira index? Can there be any corruption?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry that I could not help. I was just curious if you've found out the root cause.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.