Forums

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

updateIssue/updateValue does not update Updated field

Parisa Kabiri February 22, 2018

Hi all,

When you change a field value through the code, Jira ticket gets the updated value but "Updated" date would not be updated! Even in ticket history, there is no log that the field has been set.

Has anybody seen this problem?

I tried to update the a field in the code through following code: 

def issue = issueManager.getIssueObject("TP-16356")
def updated = "TEST VALUE"
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def textCf2 = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Plan"}
if (textCf2) {
def changeHolder = new DefaultIssueChangeHolder()
textCf2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(textCf2), updated),changeHolder)
}

 

The code works, but updateValue does not update the "Update" date field. I tried with updateIssue, it does not update the system field "Updated" either.

Is there any way to force updateIssue to update Updated field?

Thanks for your help in advance.

 JIRA Version: 7.5.3

1 answer

0 votes
Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 22, 2018

I suppose you can do this:

import java.sql.Timestamp

issue.setUpdated(new Timestamp(System.currentTimeMillis()))

This will set the value of 'Updated' field to the current time, which is time of your script execution. 

Parisa Kabiri February 26, 2018

Ivan, thanks for your help. Really appreciated.

Let me explain the situation that why we had to use setUpdated(), when you set a custom field value through code, updateIssue/updateValue must update the Updated field as well, but they don't. It worked in our previous JIRA version 6.4.7 but not in 7.5.3.

So I decided to set the field manually in the code.  issue.setUpdated sets the Updated field but it does not update the field on ticket screen, because we must force the issue to accept modified value, so we have to use again updateIssue/updateValue, but this time CustomFieldManager cannot find Update field.

The main problem is that updateIssue/updateValue methods must update automatically Update field.

Thanks for sharing me your thoughts.

Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2018

Hmm, that's odd. Both updateIssue and updateValue work for me just fine. Perhaps there's something wrong with your code?

Try this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.UpdateIssueRequest

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, UpdateIssueRequest.builder().build())
Vineela Durbha
Contributor
April 25, 2019

@Ivan Tovbin 

I am trying to use update value as below, but history is not getting updated. Do you have any idea on how to make it work?

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

Ivan Tovbin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2019
Like Joe Baldwin likes this
ashwinikumar.t.giri January 2, 2023

Hi @Ivan Tovbin 

Why did you define "user"? I am new to script runnner; could you please explain?

Does it also update the user on the issue.

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events