hi,
I have a requirement where I need to update the page property type from String to String[].
Solution 1: BULK Editor
I tried using the bulk editor extension provided in the link below, which provides a custom extension to the bulk editor tool to allow saving properties of type String[], but it failed to work.
LINK --> https://www.tothenew.com/blog/aemcq5-6-bulk-editor-extension-part-1/
AEM Version -> 6.5
Solution 2: Using Groovy script.
Is there a way we can remove a page property in groovy? and then I can create a String array and re-create the same property using the code below..
if(it.hasProperty(propertyName1))
{
String v = it.get(propertyName1);
println v;
//it.remove(propertyName1);
final String[] regionArray = [v];
it.setProperty(propertyName1,regionArray);
count++;
println 'Node with Form Path =' + nodePath + ' with property '+ propertyName1 +' = ' + it.get(propertyName1);
}
However it.remove doesnt seem to work .
Solution 3: TYPE Hint
Tried using typeHInt , but would want it to apply on all existing pages using the property as well.. so not feasible
Need help to figure out a solution.
Thanks,
Samiksha
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @samikshaa223429 ,
Setting the property to null will remove that property. You can do as below
node.setProperty(propertyName,null);
or use remove method
node.getProperty(propertyName).remove();
But dont forget to save it
session.save();
And I think you are missing session.save(); in your code.
Hope this helps!!
Thanks
Hi,
To remove the property you need to use
node.setProperty(propertyName, null)
You can use remove method also.
Sharing one sample code for property delete:
Node n = getNode('path');
n.getProperty('title').remove();
save()
Hope this helps!
Hi @samikshaa223429 ,
Setting the property to null will remove that property. You can do as below
node.setProperty(propertyName,null);
or use remove method
node.getProperty(propertyName).remove();
But dont forget to save it
session.save();
And I think you are missing session.save(); in your code.
Hope this helps!!
Thanks
Views
Likes
Replies
Views
Likes
Replies