Hello we are using Jira and are currently evaluating the Plugin "Scriptrunner for Jira" by Adaptavist.
I'd like to create a custom Listener which simply updates the value of a custom field. The field's type is a default textbox, nothing fancy there.
Regarding to the plugin's documentation and various web-searching, I came up with the following code:
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as Issue
MutableIssue issueToUpdate = (MutableIssue) issue;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'My CustomField'}
issueToUpdate.setCustomFieldValue(cf, "myvalue");
The validator does not complain about anything here and the script seems to be executed without any errors. The problem is that the custom field's value is simply not updated. Maybe some of you guys have the missing piece.
Every line seems to be needed as the validator complains otherwise. Thank you in advance for your help.