Hloo all,
Can someone help me here update the page property for all pages using groovy script
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @vinuu123 ,
Please use below groovy code to update the page property.
In this you can update the root page path, property name and value.
import javax.jcr.Node;
getNode('/content/learning').recurse { resourceNode ->
if (resourceNode.hasProperty('jcr:primaryType')) {
def primaryType = resourceNode.getProperty('jcr:primaryType').string;
if(primaryType.equals('cq:PageContent')){
resourceNode.setProperty('customProperty', 'customValue');
resourceNode.getSession().save();
}
}
}
println('All Page property updated !!!');
Regards,
Shiv
Update the above code with below line. You can also change the value /conf/we-retail/settings/wcm/segments to your project specific.
resourceNode.setProperty('cq:contextHubSegmentsPath', '/conf/we-retail/settings/wcm/segments');
Regards,
Shiv
Checkout https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/update-component-node-usin... for updating property using groovy.
import javax.jcr.Node;
getNode('/content/project').recurse {
resourceNode ->
if (resourceNode.hasProperty('cq:test')) {
resourceNode.setProperty('cq:test', 'new text');
resourceNode.getSession().save();
}
}
Views
Likes
Replies
Views
Like
Replies