Current User Same as User Custom Field
5.0.2
Verifies that the current user is equal to the value of a User custom field, in this case Sponsor.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.opensymphony.workflow.WorkflowContext
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sponsorCf = customFieldManager.getCustomFieldObjectByName("Sponsor")
if (! sponsorCf) {
log.warn ("Failed to find Sponsor field on issue: ${issue.key}")
passesCondition = false
return
}
def sponsor = issue.getCustomFieldValue(sponsorCf) as ApplicationUser
if (! sponsor) {
// Sponsor field has no value
passesCondition = false
return
}
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
passesCondition = sponsor.name == currentUser
For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.
Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.