Hi All,
We have one requirement need to write groovy script to update component node.
1.need to find the list of pages where tab component been used
tab component has multifield where each field has tab id and tab name and can author upto 5 tabs.
2. Once we get the list of pages, we need to find the component with node name navigationtabs
as shown in the below screenshot.
ex: page /content/we-retail/auotmation-support-program has tab component with node name navigationtabs and under this navTabList (multifield name) node will be there and under this 1,2,3,4,5 with nodes if author added 5 tabs. here only 2 tabs are added hence only 1 and 2 node are created.
if we take node 1 has navId and navName and need to get property navId and like that from each nodes 1,2,3,4,5 if there were 5 nodes.
then get the navId value and it should be same as node created under node navigationtabs.
here in the screenshot can see navId value is "Vendor" and this value should get updated for "By Vendor" node.
Please suggest on how to write groovy script to update node.
1.find the list of pages used tab component
2.then find the node navigationTabs and then find the navTabsList node under that.
3.then find the nodes 1,2,3,4,5 if exists under navTabsList
4.check if navId has property and get the navId property from each nodes 1,2,3,4,5
5.once we get the navId value, find under navigationTabs node and should be same as navId Value under navigationTabs node else it should be updated with navId value.
we are using AEM 6.4.5 version
Thanks,
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @gayatrik8153299,
For updating node name, we need to make use of move method from Session API - javax.jcr.Session
For your specific use case,
Assumption : (based on the screenshot shared)
Node that needs to be updated say "By Vendor" under navigationtabs is the same as navName property value. Have used this value to frame srcPath for move method mentioned above (In other words, node under navigationtabs is changed from navName value to navId value)
Note:
While executing in higher environments, have a content back up and then execute the script (in phases based on the content volume)
Check the below options:-
https://github.com/hashimkhan786/aem-groovy-scripts/blob/master/modifyProperties.groovy
Check the Example 2 in below reference
https://labs.tadigital.com/index.php/2018/12/18/groovy-script-in-aem/
Hi @gayatrik8153299,
For updating node name, we need to make use of move method from Session API - javax.jcr.Session
For your specific use case,
Assumption : (based on the screenshot shared)
Node that needs to be updated say "By Vendor" under navigationtabs is the same as navName property value. Have used this value to frame srcPath for move method mentioned above (In other words, node under navigationtabs is changed from navName value to navId value)
Note:
While executing in higher environments, have a content back up and then execute the script (in phases based on the content volume)
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies