Having Issue's Accessing An Issue's Sprint's Goal Field in Scriptrunner

I’m writing a Script Listener using Scriptrunner that accesses an issue’s associated sprint (and subsequently its goal field) and then uses it to make a put request to that same issue to update a custom “Goal” field. However, it’s failing because of how I’m trying to access the issue.

If I’m understanding the documentation right this is how issues are structured.

/*
    ------------------------------
    I S S U E   S T R U C T U R E 
    ------------------------------
    Documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-issue-issueIdOrKey-get
    ------------------------------
    issue = {
                id: "idString"
                fields: {
                            ...
                            sprint: {
                                        ...
                                        goal: "goalString"
                                        ...
                            }
                            ...
                }
        
    }
*/

I try to access “goalString” like so:

// get the issue id
def issueId = issue.id

// get the issue fields
def issueFields = issue.fields

// get the sprint
def sprint = issueFields.sprint

// get the sprint goal
def sprintGoal = sprint.goal

Since this is a Script Listener that’s set to run on issue creation/update, issue is available as a variable that contains the associated issue with Java’s Map interface. However, the script fails because the sprint variable is ultimately null. How would I gain access to an issue’s sprint and subsequently it’s goal field?

Nevermind, didn’t realize that the sprint field is a custom field and is referred to as “customfield_{id}”