Hello
I am trying to copy logged work to specific customfield using Script listener with event "Issue Commented"
Here is my code
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.comments.CommentManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
MutableIssue issueToUpdate = (MutableIssue) event.issue;
def timeWorked = issueToUpdate.getTimeSpent();
def cf = customFieldManager.getCustomFieldObjects(issueToUpdate).find {it.name == 'customfieldName'};
issueToUpdate.setCustomFieldValue(cf, timeWorked)
After comenting issue I see that listener was executed, however custom field value was not changed.
(the same problem is here: https://answers.atlassian.com/questions/35781060 )
Could you help me understand what is wrong? Is "setCustomFieldValue" correct function to update fields?
Thank you in advance,
Fyodor