Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

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

582 likes

Total Posts

564 posts

Correct Reply

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

Avatar
Establish
MVP
BrianKasingli
MVP

Likes

582 likes

Total Posts

564 posts

Correct Reply

218 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
Validate 1
Level 6
rush_pawan
Level 6

Likes

79 likes

Total Posts

155 posts

Correct Reply

63 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Validate 1
Level 6
rush_pawan
Level 6

Likes

79 likes

Total Posts

155 posts

Correct Reply

63 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
rush_pawan
Level 6

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

66 likes

Total Posts

106 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

66 likes

Total Posts

106 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
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

373 likes

Total Posts

479 posts

Correct Reply

133 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

373 likes

Total Posts

479 posts

Correct Reply

133 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
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!