Hello and happy new year.
I am having an issue with doing issue assignments via IssueService.assign(ApplicationUser, IssueService.AssignValidationResult) using ScriptRunner via the Java API. Note that when I show my code, I have attempted to isolate this issue by creating a new project and doing some trivial assigns. This is not my actual production code but just an example extract.
This project is named DEMO and it’s a simple workflow just consisting of the statuses To Do and Done, with a single transition called Done. Both the create transition and the Done transition have the same workflow to set the assignee to the reporter:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def issueService = ComponentAccessor.getIssueService()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getUserManager().getUserByName("mishelpdesk")
def reporter = issue.getReporter().getName()
def validateAssignToReporterResult = issueService.validateAssign(user, issue.id, reporter)
if (validateAssignToReporterResult.isValid()) {
issueService.assign(user, validateAssignToReporterResult)
}
In both cases, this script post-function is set as the last post-function in the transition. Here is what happens when I create a ticket with myself as the reporter, and then change the reporter back to the user mishelpdesk


Notice that in the issue history, the ticket is reassigned to mishelpdesk, but this does not persist or actually take place. However, if I execute the same function in the script console as opposed to the workflow, it works as intended.
Any idea why this would work in the create transition but not subsequent ones?