we changed a master page name from au-op to auop. now we want to display the new page name(auop) in redirect links, cta links, jcr:content & respective fields with it but they are displaying the old name(au-op). we cannot change manually all the fields. we want to change with groovy script.
Solved! Go to Solution.
Views
Replies
Total Likes
def statement = 'SELECT * from [nt:base] AS t where ISDESCENDANTNODE("/content/*") and contains(t.*, "cs-au-op")';
def query = session.getWorkspace().getQueryManager().createQuery(statement, 'JCR-SQL2');
def result = query.execute();
int count=0;
result.nodes.each { node ->
String nodePath = node.path;
def properties = node.getProperties();
properties.each { property ->
if (!property.isMultiple()) {
def propertyName = property.getName();
def propertyValue = property.getValue().getString();
if (propertyValue.contains('cs-au-op')) {
println nodePath+'/'+propertyName;
//println propertyValue;
def newPropertyValue = propertyValue.replaceAll("cs-au-op","cs-auop");
property.setValue(newPropertyValue);
session.save();
activate(node.path);
count++;
}
}
}
}
Hi @AjayAkula ,
Check the below example. It will surely help you.
https://github.com/hashimkhan786/aem-groovy-scripts/blob/master/modifyProperties.groovy
Hi,
You should do this with page move api, which could have taken care of references update as well.
def statement = 'SELECT * from [nt:base] AS t where ISDESCENDANTNODE("/content/*") and contains(t.*, "cs-au-op")';
def query = session.getWorkspace().getQueryManager().createQuery(statement, 'JCR-SQL2');
def result = query.execute();
int count=0;
result.nodes.each { node ->
String nodePath = node.path;
def properties = node.getProperties();
properties.each { property ->
if (!property.isMultiple()) {
def propertyName = property.getName();
def propertyValue = property.getValue().getString();
if (propertyValue.contains('cs-au-op')) {
println nodePath+'/'+propertyName;
//println propertyValue;
def newPropertyValue = propertyValue.replaceAll("cs-au-op","cs-auop");
property.setValue(newPropertyValue);
session.save();
activate(node.path);
count++;
}
}
}
}
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies