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
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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())
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.
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()
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.