Update AEM Page Properties in bulk

Avatar

Avatar
Level 1
Anantha
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
Anantha
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
Anantha
Level 1

28-04-2021

Hi, We 100+ pages under sites and we have a requirement to update the fields in basic and also custom metadata fields. can you please let me know if there is a way to update the page metadata properties in bulk?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

647 likes

Total Posts

608 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

647 likes

Total Posts

608 posts

Correct reply

239 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
BrianKasingli
MVP

28-04-2021

@Anantha,

You can do this in multiple ways. 

1. Servlet - you can create a servlet that you would call to invoke OSGI backend operations on your AEM content pages. As an extra safety measure, you can create a content package from production, upload it into your development environment, and then run the servlet. Once when the content has been updated, package up the content and upload + install back into production.

2. Our of the box "edit" feature - From the Touch UI, you can select multiple pages, and then click on the edit button; this will allow you to edit page properties for more than 1 page, all together. 

3. AEM Groovy Script Console - with your groovy console plugin within your AEM environment, https://github.com/icfnext/aem-groovy-console, you can write a custom groovy script that you would call to invoke OSGI backend operations on your AEM content pages. As an extra safety measure, you can create a content package from production, upload it into your development environment, and then run the servlet. Once when the content has been updated, package up the content and upload + install back into production.

 

 

Answers (3)

Answers (3)

Avatar

Avatar
Boost 100
Level 7
rush_pawan
Level 7

Likes

127 likes

Total Posts

192 posts

Correct reply

81 solutions
Top badges earned
Boost 100
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Boost 100
Level 7
rush_pawan
Level 7

Likes

127 likes

Total Posts

192 posts

Correct reply

81 solutions
Top badges earned
Boost 100
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile
rush_pawan
Level 7

28-04-2021

hello,

refer this, it will give you good idea to move forward  https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/bulk-editing.... 

 

Avatar

Avatar
Springboard
Level 4
bilal_ahmad
Level 4

Likes

67 likes

Total Posts

108 posts

Correct reply

16 solutions
Top badges earned
Springboard
Validate 10
Validate 1
Ignite 1
Establish
View profile

Avatar
Springboard
Level 4
bilal_ahmad
Level 4

Likes

67 likes

Total Posts

108 posts

Correct reply

16 solutions
Top badges earned
Springboard
Validate 10
Validate 1
Ignite 1
Establish
View profile
bilal_ahmad
Level 4

28-04-2021

Hey @Anantha, few suggestions:
1. If your pages have same sling:resourceTtpe i.e they use same page templates, then you can leverage OOTB bulk edit:

bilal_ahmad_0-1619678318820.png

 

2. Use Groovycripts to update the properties. For that you need to first write a query that will find out all your relevant pages(keeping page template or any other property(ies)) in mind. You need to be careful if you have excluded any path(s) in your custom index definition(oak:index) because sometimes we don't want certain page(s) or path(s) to show up when we query them.

Thanks,

Bilal.

 

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

206 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

206 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

28-04-2021

Hi @Anantha 

 

You can create a Sling Servlet that can accept specific query parameters, which allows you to manipulate and change properties using CRUD API.

CRUD API - https://sling.apache.org/documentation/the-sling-engine/sling-api-crud-support.html

 

The servlet will accept parameters as "resourcePath", "propertyName", "propertyValue".
example: [POST] /bin/update-resource
resourcePath=/content/my-site/folder;
propertyName=testpropertyName;
propertyValue=true

 

Iterate through all the pages and then update, else you can do page wise also if the values are different:

public class SimpleServlet extends SlingAllMethodsServlet {

private static final long serialVersionUID = 1L;

@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {
ResourceResolver resourceResolver = getResourceResolver();
String path = Read from Request;
String propertyName = Read from Request;
String propertyValue = Read from Request;
Resource myResource = resourceResolver.getResource(path);
ModifiableValueMap properties = myResource.adaptTo(ModifiableValueMap.class);
properties.put(propertyName, propertyValue);
resourceResolver.commit();
}
}

 

Thanks!