Release Note Template - $issue not hydrated per documentation

I’m trying to do a custom template. I’ve cut and pasted the example from https://developer.atlassian.com/server/jira/platform/creating-a-custom-release-notes-template-containing-release-comments/ which is for using CustomFields.

In debugging why the field does not show, I’ve deduced that inside the macro, the object $issue.project is null for the call $issue.project.getLong(“id”) on line 2 of the example.

Why might this be the case?

Note: I’m using Data Center Jira, version v11.3.1

You’ll have to pass the issue object into the macro and you can’t just use $issue as that variable is not populated initially.

When looking at a simplified version of the example:

#foreach ($issueType in $issueTypes)
#foreach ($issue in $issueType.issues)
#getReleaseNoteComment($issue $customFieldManager)
#end
#end

We can assume that $issueTypes is populated with a collection. Using a foreach loop you can iterate over this collection. This statement also populates the $issueType variable (within the loop). Then you can access the issues field on the $issueType variable and iterate over it using another foreach loop while also populating the $issue variable. Finally you can pass the $issue variable into the getReleaseNoteComment macro.