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