<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: To unable cm:autoVersionOnUpdateProps in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86926#M26233</link>
    <description>&lt;P&gt;You did right, you need to add the properties in alfresco-global.properties. Either platform project or docker project's&amp;nbsp;alfresco-global.properties should work.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Refer this post for more details:&amp;nbsp;&lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-forum/versioning-properties/m-p/298655/highlight/true#M19199" target="_blank" rel="noopener nofollow noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-forum/versioning-properties/m-p/298655/highlight/true#M19199&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-forum/version-history-does-not-include-property-updates/m-p/297112/highlight/true#M18250" target="_blank" rel="nofollow noopener noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-forum/version-history-does-not-include-property-updates/m-p/297112/highlight/true#M18250&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jun 2020 15:07:50 GMT</pubDate>
    <dc:creator>abhinavmishra14</dc:creator>
    <dc:date>2020-06-10T15:07:50Z</dc:date>
    <item>
      <title>To unable cm:autoVersionOnUpdateProps</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86925#M26232</link>
      <description>&lt;P&gt;Hii All,&lt;/P&gt;&lt;P&gt;I want to unable versioning on properties and want&amp;nbsp;&lt;SPAN&gt;cm:autoVersionOnUpdateProps to be true.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have added this two changes in both docker alfresco-global.properties and platform alfresco-global.properties.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;version.store.enableAutoVersioning=true&lt;BR /&gt;version.store.enableAutoVersionOnUpdateProps=true&lt;/P&gt;&lt;P&gt;please notify me changes to be made with path. I am attaching screenshot which is showing autoVersionOnUpdateProps to be false.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot (29).png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://connect.hyland.com/t5/image/serverpage/image-id/688i2AEB707A110D0939/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 14:54:13 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86925#M26232</guid>
      <dc:creator>piyush48</dc:creator>
      <dc:date>2020-06-10T14:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: To unable cm:autoVersionOnUpdateProps</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86926#M26233</link>
      <description>&lt;P&gt;You did right, you need to add the properties in alfresco-global.properties. Either platform project or docker project's&amp;nbsp;alfresco-global.properties should work.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Refer this post for more details:&amp;nbsp;&lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-forum/versioning-properties/m-p/298655/highlight/true#M19199" target="_blank" rel="noopener nofollow noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-forum/versioning-properties/m-p/298655/highlight/true#M19199&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://hub.alfresco.com/t5/alfresco-content-services-forum/version-history-does-not-include-property-updates/m-p/297112/highlight/true#M18250" target="_blank" rel="nofollow noopener noreferrer"&gt;https://hub.alfresco.com/t5/alfresco-content-services-forum/version-history-does-not-include-property-updates/m-p/297112/highlight/true#M18250&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 15:07:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86926#M26233</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-06-10T15:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: To unable cm:autoVersionOnUpdateProps</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86927#M26234</link>
      <description>&lt;P&gt;Hi &lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/74498"&gt;@abhinavmishra14&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Piyush&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 05:58:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86927#M26234</guid>
      <dc:creator>piyush48</dc:creator>
      <dc:date>2020-06-11T05:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: To unable cm:autoVersionOnUpdateProps</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86928#M26235</link>
      <description>&lt;P&gt;You can write a repository tier webscript (java or javascript) to cleanup nodes where "&lt;SPAN&gt;cm:autoVersionOnUpdateProps&lt;/SPAN&gt;" property is set to false.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Javascript based webscript can be directly deployed to "Data Dictionary &amp;gt; Web Scripts Extensions " directory without restarting the server. Follow the document here to learn more:&amp;nbsp;&lt;A href="https://docs.alfresco.com/6.2/tasks/ws-config.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/6.2/tasks/ws-config.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Learn more on creating webcripts here:&amp;nbsp;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/6.2/concepts/ws-overview.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/6.2/concepts/ws-overview.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html#what-is-the-web-script-framework" target="_blank" rel="noopener nofollow noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html#what-is-the-web-script-framework&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Steps you would do in the webscript:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;1- Prepare a search query to return the nodes having&amp;nbsp;&amp;nbsp;"&lt;SPAN&gt;cm:autoVersionOnUpdateProps&lt;/SPAN&gt;" 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.&lt;/P&gt;
&lt;P&gt;2- Once nodes are returned, double check that whether "&lt;SPAN&gt;cm:autoVersionOnUpdateProps&lt;/SPAN&gt;" property is false, if true- set the property value to true&lt;/P&gt;
&lt;P&gt;3- save the node&lt;/P&gt;
&lt;P&gt;-------------------&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;PRE&gt;&lt;U&gt;&lt;STRONG&gt;cleanupProperty.get.desc.xml
&lt;/STRONG&gt;&lt;/U&gt;
&amp;lt;webscript&amp;gt;
	&amp;lt;shortname&amp;gt;Cleanup existing value of a property&amp;lt;/shortname&amp;gt;
	&amp;lt;description&amp;gt;Cleanup existing value of a property&amp;lt;/description&amp;gt;
	&amp;lt;url&amp;gt;/cleanupProperty?propertyName={propertyName}&amp;amp;amp;existingPropertyVal={existingPropertyVal}&amp;amp;amp;newPropertyVal={newPropertyVal}&amp;amp;amp;folderPath={folderPath}&amp;amp;amp;siteShortName={siteShortName}&amp;amp;amp;contentTypes={contentTypes}&amp;amp;amp;skipCount={skipCount}&amp;amp;amp;maxCount={maxCount}&amp;lt;/url&amp;gt;
	&amp;lt;format default="html"&amp;gt;any&amp;lt;/format&amp;gt;
  	&amp;lt;authentication&amp;gt;admin&amp;lt;/authentication&amp;gt;
&amp;lt;/webscript&amp;gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;U&gt;cleanupProperty.get.html.ftl&lt;/U&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Cleanup existing value of a property&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;h4&amp;gt;Nodes which failed during update&amp;lt;/h4&amp;gt;
	&amp;lt;#if failedNodes?is_hash_ex&amp;gt;
	  &amp;lt;#assign keys = failedNodes ?keys&amp;gt;
		&amp;lt;#list keys as key&amp;gt;${key} - ${failedNodes [key]}; &amp;lt;br&amp;gt;&amp;lt;/#list&amp;gt;
	&amp;lt;/#if&amp;gt;

	&amp;lt;h4&amp;gt;Successfully updated nodes&amp;lt;/h4&amp;gt;
	&amp;lt;#if successNodes?is_hash_ex&amp;gt;
	   &amp;lt;#assign keys = successNodes ?keys&amp;gt;
		 &amp;lt;#list keys as key&amp;gt;${key} - ${successNodes [key]}; &amp;lt;br&amp;gt;&amp;lt;/#list&amp;gt;
	&amp;lt;/#if&amp;gt;
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;STRONG&gt;&lt;U&gt;cleanupProperty.get.js
&lt;/U&gt;&lt;/STRONG&gt;
main();

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.name);
              node[propertyName] = newPropertyVal;
              node.save();
              successNodes[node.nodeRef] = node.name+" - Success";
		} catch(ex) {
			logger.log("Exception occurred: "+ex.message);
			failedNodes[node.nodeRef] = node.name+" - "+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&amp;lt;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&amp;lt;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 &amp;amp;&amp;amp; (propertyName=="mimetype" || propertyName=="size")) {
           
           query = query +' AND @content.'+propertyName+':"'+existingPropertyVal+'"';
        } else {
           query = query +' AND @'+propertyParts[0]+'\\:'+propertyParts[1]+':"'+existingPropertyVal+'"';
        }
    }
    return query;
}&lt;/PRE&gt;
&lt;P&gt;To execute the webscript, e.g.:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://127.0.0.1:800/alfresco/service/cleanupProperty?propertyName=cm:autoVersionOnUpdateProps&amp;amp;existingPropertyVal=false&amp;amp;newPropertyVal=true&amp;amp;siteShortName=test-site&amp;amp;contentTypes=cm:content" target="_blank" rel="noopener nofollow noreferrer"&gt;http://127.0.0.1:800/alfresco/service/cleanupProperty?propertyName=cm:autoVersionOnUpdateProps&amp;amp;existingPropertyVal=false&amp;amp;newPropertyVal=true&amp;amp;siteShortName=test-site&amp;amp;contentTypes=cm:content&lt;/A&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can utilize the folder path as well as use multiple content types (',' separated) as param.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I would strongly recommed to go through the tutorials and docs given above for better understanding and future prospects of webscript development.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 12:36:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/to-unable-cm-autoversiononupdateprops/m-p/86928#M26235</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-06-11T12:36:06Z</dc:date>
    </item>
  </channel>
</rss>

