How to retrieve boards from a specific project


I’m trying to retrieve boards from a specific project so that I can clone them and attach them to a new project.
I’m successful in retrieving the project itself, but the following line of code returns false:

That project has 3 boards.

Here’s a snippet the script:
def projectManager = ComponentAccessor.projectManager
def sourceProject = projectManager.getProjectByCurrentKey(“IDPTDND”)
def targetProject = projectManager.getProjectByCurrentKey(“MTP”)

BoardManager boardManager = (BoardManager)ComponentAccessor.getOSGiComponentInstanceOfType(BoardManager.class)

sb.append(" Are there any boards? " + boardManager.hasBoardForProject( + " ||");

return sb.toString()