Hello together,
is it possible to edit the page properties via Java Script? I would have to do this for 4000 pages, which would take a very long time manually.
The script must go to the page properties --> Advanced tab --> Break inheritance --> Check an option --> Close inheritance and activate the page.
Can you provide such a possibility via a script that can be executed in CRX?
best
CK
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Darwin
You can use groovy scripts to achieve this. Here are some of the articles that might help you.
https://labs.tadigital.com/index.php/2018/12/18/groovy-script-in-aem/
https://hashimkhan.in/aem-adobecq5-code-templates/groovy-script/
Thanks
Hi @Darwin
You can use groovy scripts to achieve this. Here are some of the articles that might help you.
https://labs.tadigital.com/index.php/2018/12/18/groovy-script-in-aem/
https://hashimkhan.in/aem-adobecq5-code-templates/groovy-script/
Thanks
Hey @JeevanRaj Did you get a chance to explore ACS Commons Data Importer Utility. It allows you to import bulk data using csv into AEM.
Hi @Darwin, I think using JS will not be the proper option. Groovy console as @JeevanRaj suggest is the way to go. Below you can find simple groovy script that I believe do what you need.
import com.day.cq.wcm.msm.api.LiveRelationshipManager import org.apache.sling.api.resource.ModifiableValueMap // array of properties that should be changed def propertyNames = ["jcr:title"] as String[] // map of propertyName:newValue def propertyValues = ["jcr:title":"new value"] // array of page paths that should be changed def pagePaths = ["/content/we-retail/us/en/men"] as String[] def liveRelationshipManager = getService(LiveRelationshipManager.class) pagePaths?.each { pagePath -> def pageResource = resourceResolver.getResource(pagePath) def liveRelationship = liveRelationshipManager.getLiveRelationship(pageResource, true) liveRelationshipManager.cancelPropertyRelationship(resourceResolver, liveRelationship, propertyNames, true) def jcrContentResource = resourceResolver.getResource(pageResource?.path + "/jcr:content") def valueMap = jcrContentResource?.adaptTo(ModifiableValueMap.class) println "Page has been updated ${pageResource?.path}" propertyNames?.each { property -> valueMap.put(property, propertyValues[property]) println "Property has been changed ${property}" } resourceResolver.commit() // activating jcr:content because this is place where page properties are stored and this node has been changed activate(jcrContentResource?.path) }
Hi @lukasz-m
The above Groovy Script what you have given is working for only Title change, But If we want to replace one word in whole page then how it is possible.
Ex: In one page there is a one work is called ADOBE EXPERIENCE MANAGER(wordToFind) I want to replace with AEM(wordToReplace) in whole page (In Title, Description, Overview etc...)
Please help me in this scenario with Groovy Script.
Thanks
Views
Replies
Total Likes