Update text field
Asked by Viktor Fedun:

Hi, why does update field value + update issue are not actually updating issue fields?  
I have a script  

<br />

```
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.event.type.EventDispatchOption

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueByCurrentKey("EQ-114892")
def customField = customFieldManager.getCustomFieldObject("customfield_24100") //text-field

if (issue && customField) {

    def changeHolder = new DefaultIssueChangeHolder();
    def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser;

    def customFieldValue = issue.getCustomFieldValue(customField)
    log.debug("The value of ${customField.getName()} for issue ${issue.getKey()} is: ${customFieldValue}") //any value allowed here, initial

    customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), null),changeHolder);
    issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false);
    customFieldValue = issue.getCustomFieldValue(customField)
    log.debug("The value of ${customField.getName()} for issue ${issue.getKey()} is: ${customFieldValue}") //should be null

    customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), "1234567"),changeHolder);
    issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false);
    customFieldValue = issue.getCustomFieldValue(customField)
    log.debug("The value of ${customField.getName()} for issue ${issue.getKey()} is: ${customFieldValue}") //should be 1234567

    customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), issue.getCustomFieldValue(customField) + "890"),changeHolder);
    issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false);
    customFieldValue = issue.getCustomFieldValue(customField)
    log.debug("The value of ${customField.getName()} for issue ${issue.getKey()} is: ${customFieldValue}") //should be 1234567890

}
```

but the results are   

<br />

```
2024-06-25 11:34:35,006 DEBUG [runner.ScriptBindingsManager]: The value of JSON for issue EQ-114892 is: 1234567890890890890890890890
2024-06-25 11:34:35,010 DEBUG [runner.ScriptBindingsManager]: The value of JSON for issue EQ-114892 is: 1234567890890890890890890890
2024-06-25 11:34:35,014 DEBUG [runner.ScriptBindingsManager]: The value of JSON for issue EQ-114892 is: 1234567890890890890890890890
2024-06-25 11:34:35,019 DEBUG [runner.ScriptBindingsManager]: The value of JSON for issue EQ-114892 is: 1234567890890890890890890890
```


Answers:
author: Florian Bonniec
body: Hi [@Viktor Fedun](/t5/user/viewprofilepage/user-id/5287812)

If the version of scriptrunner is recent I suggest you to use HAPI instead.

[Update Fields (adaptavist.com)](https://docs.adaptavist.com/sr4js/latest/hapi/update-fields)

Regards


Tags: data-center

jira-data-center

jira-service-management

jira-service-management-server

server