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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Can we change jcr:primaryType of the node after it is created

Avatar

Level 2

Hi,

I am having requirement to add a custom folder properties , but my folder are created dynamically as nt:folder from backend. 

Since folder schema only applies to sling:folder, wanted to check if we can change the folder primary type in JCR.

0 Replies

Avatar

Level 4

Yes, you can change folder from code by giving same name to the folder, just change  jcr:primaryType="sling:Folder"

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:Folder"
    jcr:title="test folder project"
    sling:resourceType="sling:Folder"/>

in filter.xml, you can update

<filter root="/<foolder-destination>/testfolder" mode="update"/>

 earlier testfolder was "nt:folder" now updated to sling:Folder

HeenaMadan_0-1659019513203.png

Thanks

Avatar

Level 8

jcr:primaryType is a protected property and can not be changed or removed by the application using the API. Please refer this document for more details :

 

https://developer.adobe.com/experience-manager/reference-materials/spec/jcr/1.0/6.7.5_Special_Proper...

 

You can restructure the old folders with Sling:Folder as jcr:primaryType using some script and update existing BE logic to create the folder as sling:Folder.