change the childtype of a DocumentLibrary to cm:folder

cancel
Showing results for 
Search instead for 
Did you mean: 
yohanmaker
Member II

change the childtype of a DocumentLibrary to cm:folder

hello everyone, and thanks for reading this,

the document Library of one of my sites changed unexpectly to "type: websiteContainer", now it is not accesible anymore from the front-end in share.

is there a way to change it back to "type: cm_folder"?

Screen Shot 2022-01-05 at 11.08.50.png

1 Reply
abhinavmishra14
Advanced

Re: change the childtype of a DocumentLibrary to cm:folder

You can use JSConsole or write a js repository webscript to change the type back to cm:folder. You can use nodeService's setType method to change the type.

These amps works with acs7 if you would like to install and use the JSConsole:

https://github.com/abhinavmishra14/js-console/releases/download/0.7-rc/javascript-console-repo-0.7.a...

https://github.com/abhinavmishra14/js-console/releases/download/0.7-rc/javascript-console-share-0.7....

Here is a video on how to use it: https://www.youtube.com/watch?v=c3JIeVY8Nnk

Here is a sample code that can be used to change the type via JSConsole:

var nodeRefStr = 'workspace://SpacesStore/e0df9384-9472-472e-95c0-2e091f452700'; //Node ref of the corrupted folder
try {
	var node=search.findNode(nodeRefStr);
	logger.log("NodeRef: "+ node.nodeRef+" | Name: "+node.name)
        var ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
        var nodeService =  ctxt.getBean('NodeService', org.alfresco.service.cmr.repository.NodeService);
        var QName = Packages.org.alfresco.service.namespace.QName;
        var nodeTypeFolder = QName.createQName("{http://www.alfresco.org/model/content/1.0}folder");
        nodeService.setType(node.nodeRef, nodeTypeFolder);
} catch (ex) {
   logger.log("Exception occurred: " + ex.message);
}

If you prefer to use js repository web script, here are the documentations to start with:

https://docs.alfresco.com/content-services/7.0/tutorial/platform/web-scripts/

https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/web-scripts/

 

 

~Abhinav
(ACSCE, AWS SAA, GAIQ)