I have a simple workflow with three serial approval nodes.
The first node is setup to approve on the basis of the users in the Approval field and the field is set as a default value from the Service Desk request type. This user gets the approve/deny email.
Whether or not the trigger is from the email or from inside Jira itself, the approval transition is not followed. I do have a ScriptRunner post-function that resets the Approver field. The post-function does indicate that it is triggered, but somehow I am not ending up at the next status.
Here's the script: (<uesrname> hidden)
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
ApplicationUser approver = ComponentAccessor.getUserManager().getUserByKey("<username>")
issue.setCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Approvers"), approver)
Any suggestions?
The problem was a silly mistake. The Approver field requires an array or collection as the second parameter to setCustomFieldValue(), not a single ApplicationUser object.
New script is:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
ApplicationUser approver = ComponentAccessor.getUserManager().getUserByKey('<username>')
//log.error 'approver: ' + approver
def customFieldCollection = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName('Approvers')
CustomField field = customFieldCollection.find {it.getFieldName() == 'Approvers'}
//log.error 'field: ' + field
try {
issue.setCustomFieldValue(field, [approver])
}
catch (Exception ex) {
log.error ex.getMessage()
}
//log.error 'end'
Hi @Paul Tiseo
your transition is probably throwing an error. Can you access the jira logs?
I would also recommend adding some log statements and/or checks on values returned by your api calls to check they are working as you expect.
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.