Expand my Community achievements bar.

SOLVED

update the page property for all pages using groovy script

Avatar

Level 3

Hloo all,

Can someone help me here update the page property for all pages using groovy script

1 Accepted Solution

Avatar

Correct answer by
Level 3

hi @Shiv_Prakash_Patel ,

need to update/change this path in all pages using groovy script

vinuu123_0-1685017258869.png

 

4 Replies

Avatar

Level 6

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

 

Avatar

Correct answer by
Level 3

hi @Shiv_Prakash_Patel ,

need to update/change this path in all pages using groovy script

vinuu123_0-1685017258869.png

 

Avatar

Level 6

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

page footer