To unable cm:autoVersionOnUpdateProps

Showing results for 
Search instead for 
Did you mean: 
Active Member II

To unable cm:autoVersionOnUpdateProps

Hii All,

I want to unable versioning on properties and want cm:autoVersionOnUpdateProps to be true.

I have added this two changes in both docker and platform

please notify me changes to be made with path. I am attaching screenshot which is showing autoVersionOnUpdateProps to be false.

Screenshot (29).png

3 Replies

Re: To unable cm:autoVersionOnUpdateProps

You did right, you need to add the properties in Either platform project or docker project's should work.

It will take effect for all newly created nodes. But for existing nodes, you have to write a script to reset the property and set value to true.

Refer this post for more details:

Active Member II

Re: To unable cm:autoVersionOnUpdateProps

Hi @abhinavmishra14 ,

Thanks for making me understand how this work with old Node. Could you please guide me for Script how to create and Path to Place it in SDK?? That will be very helpful.





Re: To unable cm:autoVersionOnUpdateProps

You can write a repository tier webscript (java or javascript) to cleanup nodes where "cm:autoVersionOnUpdateProps" property is set to false. 

Javascript based webscript can be directly deployed to "Data Dictionary > Web Scripts Extensions " directory without restarting the server. Follow the document here to learn more:

Learn more on creating webcripts here:

Steps you would do in the webscript:

1- Prepare a search query to return the nodes having  "cm:autoVersionOnUpdateProps" property as false. You could choose to do site by site/folder by folder or get all sites and iterate your search query using site short name.

2- Once nodes are returned, double check that whether "cm:autoVersionOnUpdateProps" property is false, if true- set the property value to true

3- save the node


If you decide to use javascript based repo webscript, here is a sample webscript which you can try and make changes/tweak as per your need.


	<shortname>Cleanup existing value of a property</shortname>
	<description>Cleanup existing value of a property</description>
	<format default="html">any</format>

<html> <head> <title>Cleanup existing value of a property</title> </head> <body> <h4>Nodes which failed during update</h4> <#if failedNodes?is_hash_ex> <#assign keys = failedNodes ?keys> <#list keys as key>${key} - ${failedNodes [key]}; <br></#list> </#if> <h4>Successfully updated nodes</h4> <#if successNodes?is_hash_ex> <#assign keys = successNodes ?keys> <#list keys as key>${key} - ${successNodes [key]}; <br></#list> </#if> </body> </html>


function main(){
	var propertyName =  args["propertyName"];
    var existingPropertyVal = args["existingPropertyVal"];
    var newPropertyVal = args["newPropertyVal"];
    var contentTypes = args["contentTypes"];
	var siteShortName = args["siteShortName"];
    var folderPath = args["folderPath"];
	var skipCount = (args["skipCount"]==null || args["skipCount"]==undefined)?0:args["skipCount"];
	var maxCount = (args["maxCount"]==null || args["maxCount"]==undefined)?100000:args["maxCount"];
	var successNodes = [];
	var failedNodes = [];
    var query = buildSearchQuery(siteShortName, contentTypes, folderPath, propertyName, existingPropertyVal)
	var page = {
			skipCount : parseInt(skipCount),
			maxItems : parseInt(maxCount)

	var searchQuery = {
			query : query,
			language : "fts-alfresco",
			page : page
 	logger.log("Executing Search: "+query)
 	var nodes = search.query(searchQuery);
 	logger.log("Total Nodes found: "+nodes.length)
    for each(node in nodes) {
		try {
              logger.log("Updating the "+propertyName+" of node: ";
              node[propertyName] = newPropertyVal;
              successNodes[node.nodeRef] =" - Success";
		} catch(ex) {
			logger.log("Exception occurred: "+ex.message);
			failedNodes[node.nodeRef] =" - "+ex.message;
	model.successNodes = successNodes;
	model.failedNodes = failedNodes;

function buildSearchQuery(siteShortName, contentTypes, folderPath, propertyName, existingPropertyVal) {
    var query = 'PATH:"/app:company_home/st:sites/cm:' +siteShortName;
    if(folderPath=="") {
       query = query + '/cm:documentLibrary//*"';
    } else {
       query = query + '/cm:documentLibrary/';
       var pathTokens = folderPath.split('/');
       for (var each=0; each<pathTokens.length; each ++) {
         query = query +'cm:'+search.ISO9075Encode(pathTokens[each].trim())+'/';
       query = query + '/*"';

    var contentTypeArr = contentTypes.split(',');
	var arrayLength = contentTypeArr.length;

	if(arrayLength == 1) {
		query = query +' AND (TYPE:"' +contentTypeArr+'")';
	} else {
		query = query +' AND (';
		for (var each=0; each<arrayLength; each ++) {
			query = query + 'TYPE:"'+contentTypeArr[each].trim()+'"';
			if(each != arrayLength-1) {
				query = query + ' OR ';
		query = query +')';
    //Append property and value query.
    if(!!existingPropertyVal) {
        var propertyParts = propertyName.split(':');
        if (propertyParts.length ==1 && (propertyName=="mimetype" || propertyName=="size")) {
           query = query +' AND @content.'+propertyName+':"'+existingPropertyVal+'"';
        } else {
           query = query +' AND @'+propertyParts[0]+'\\:'+propertyParts[1]+':"'+existingPropertyVal+'"';
    return query;

To execute the webscript, e.g.:

You can utilize the folder path as well as use multiple content types (',' separated) as param.

I would strongly recommed to go through the tutorials and docs given above for better understanding and future prospects of webscript development.