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
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
Thanks for the code and yes it worked.
Can i know why do we need IssueIndexingService?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am writing this code under Workflow Transitions(post function) not in a listener.
So do I need to add that code for indexing?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.