Groovy console help
Hi everyone,
I am using the Groovy Console in AEM to update a custom property demo:status to "archieved" for all pages under /content/demo/en/archive that have a cq:template of myproject/components/page/article.
Here is the script:
def rootPath = "/content/my-site/en/archive"
def resourceResolver = resourceResolverFactory.getServiceResourceResolver(null)
def session = resourceResolver.adaptTo(Session)
def query = "SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE([${rootPath}]) AND s.[cq:template] = 'myproject/components/page/article'"
def result = session.workspace.queryManager.createQuery(query, "JCR-SQL2").execute()
result.nodes.each { node ->
def contentNode = node.getNode("jcr:content")
contentNode.setProperty("myProject:status", "archived")
println "Updated: ${node.path}"
}
session.save()
But I keep getting errors: javax.jcr.PathNotFoundException: jcr:content Can someone help me understand what’s wrong here?