Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

updateValue method not updating jira issue history

Vineela Durbha
Contributor
April 25, 2019

I am trying to update the jira customfield using update value method as below

brlckDate.updateValue(null,linkedIssue,new ModifiedValue(brlckIssueCfValue,brtime),new DefaultIssueChangeHolder())

 

It is being updated but is not being shown in history of the ticket.

 

Can someone help me on this

1 answer

1 accepted

2 votes
Answer accepted
Antoine Berry
Community Champion
April 25, 2019

Hi @Vineela Durbha ,

Kindly try this snippet : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.type.*

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

int cfId = 11001
//set this to true if you want to send mail on this event
boolean sendMail = false
def cfObject = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(cfId)
linkedIssue.setCustomFieldValue(cfObject, brtime)
issueManager.updateIssue(user, linkedIssue, EventDispatchOption.ISSUE_UPDATED, sendMail)

def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
linkedIssue.store()
issueIndexingService.reIndex(linkedIssue)

Antoine

Vineela Durbha
Contributor
April 25, 2019

Hi @Antoine Berry 

Thanks for the code and yes it worked.

Can i know why do we need IssueIndexingService?

Antoine Berry
Community Champion
April 25, 2019

Indeed you do not need it. There may be a case in the past where the reindex was not performed but the ISSUE_UPDATED event will reindex the issue, so you can get rid of that part (last 3 lines).

If you are satisfied with the answer please consider marking it as accepted. :)

Antoine

Vineela Durbha
Contributor
April 25, 2019

@Antoine Berry 

I am writing this code under Workflow Transitions(post function) not in a listener.

So do I need to add that code for indexing?

Antoine Berry
Community Champion
April 25, 2019

No you do not need to add that code. It should be ok by itself. If you want to be extra sure, just put that script postfunction prior to the "Update change history for an issue and store the issue in the database." postfunction.

Antoine

Suggest an answer

Log in or Sign up to answer