<?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: create folder with document.properties and push files into this folder in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114413#M31774</link>
    <description>&lt;P&gt;Thank you again to take care about me !&lt;/P&gt;&lt;P&gt;Here is the code for now :&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];
var parent = document.parent;
var myfolder = parent.childByNamePath(Descr);
if (myfolder === null) {
    myfolder = parent.createFolder(Descr);
}
document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;But script failed&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Caused by: java.lang.NullPointerException: Illegal null path&lt;/PRE&gt;&lt;P&gt;I didn't paste all the javalog to not spam, but i can if you need all logs&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2019 10:58:27 GMT</pubDate>
    <dc:creator>castelsarrasin</dc:creator>
    <dc:date>2019-12-06T10:58:27Z</dc:date>
    <item>
      <title>create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114406#M31767</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Hi !&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have Alfresco community 5.2f&lt;/P&gt;&lt;P&gt;How can i create folder containing the name of some properties and push the files who get the same properties value in this new folder ?&lt;/P&gt;&lt;P&gt;Exemple :&lt;/P&gt;&lt;P&gt;File 1 have properties-test= XXX&lt;/P&gt;&lt;P&gt;File 2 have properties-test= XXX&lt;/P&gt;&lt;P&gt;then create folder "XXX"&amp;nbsp;&lt;/P&gt;&lt;P&gt;then push those files in "XXX" folder&lt;/P&gt;&lt;P&gt;Tell me what you need to know to help me, i'll answer.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 14:50:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114406#M31767</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-11-15T14:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114407#M31768</link>
      <description>&lt;P&gt;Implement a &lt;STRONG&gt;folder rule&lt;/STRONG&gt; or Implement a &lt;STRONG&gt;behavior&lt;/STRONG&gt; which can listen to onCreateNode event and moves the files by creating the folder based on available metadata. With bevahior implementation, you get more control over the operation.&lt;/P&gt;
&lt;P&gt;When the file will be uploaded, this behavior will trigger as soon as onCreateNode event is issues and does the required job. Your logic will go into&amp;nbsp;onCreateNode method which you would implement for&amp;nbsp;NodeServicePolicies.OnCreateNodePolicy&lt;/P&gt;
&lt;PRE&gt;/* (non-Javadoc)
	 * @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
	 */
	@Override
	public void onCreateNode(final ChildAssociationRef childAssocNode) {
		//Your logic goes here.
			}
		}
	}&lt;/PRE&gt;

&lt;P&gt;Refer this documentation on creating the behavior:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://ecmarchitect.com/alfresco-developer-series-tutorials/behaviors/tutorial/tutorial.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/5.2/references/dev-extension-points-behaviors.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://docs.alfresco.com/5.2/references/dev-extension-points-behaviors.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 17:48:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114407#M31768</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2019-11-15T17:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114408#M31769</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;abhinavmishra14&amp;nbsp;&lt;SPAN class="login-bold"&gt;!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;I just start on java and if possible, i would like to not use web script (i'm more than a noob with it)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Actually my script look like this and is executed by rules in a folder :&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];
var myfolder = userhome.createFolder(Descr);&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;this is the catalina log :&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;Caused by: org.alfresco.service.cmr.model.FileExistsException: 10194109 Le fichier ou dossier 19005114 existe déjà&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;It's french and it mean that the folder already exist.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;19005114 is the propertie name i want to have fore the folder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;It already exist because 2 files get the same metadata so my script try to create 2 time the same file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Now i want a condition that if it exist, so it create the folder and push the X documents who have same metadata into the folder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thank by advance !&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 08:49:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114408#M31769</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-11-19T08:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114409#M31770</link>
      <description>&lt;P&gt;The same folder, not the same file sorry&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 09:05:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114409#M31770</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-11-19T09:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114410#M31771</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;It seems that you are looking for something like that:&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];
var myfolder = userhome.childByNamePath(Descr);
if (myfolder === null) {
    myfolder = userhome.createFolder(Descr);
}
document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 12:49:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114410#M31771</guid>
      <dc:creator>roberto_gamiz</dc:creator>
      <dc:date>2019-11-19T12:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114411#M31772</link>
      <description>&lt;P&gt;Thank you very much !&lt;/P&gt;&lt;P&gt;It nearly work as i want to.&lt;/P&gt;&lt;P&gt;Except that it move the folder in my share/user folder.&lt;/P&gt;&lt;P&gt;This script is set for a Site.&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];
var myfolder = &lt;FONT color="#FF0000"&gt;userhome.childByNamePath&lt;/FONT&gt;(Descr);
if (myfolder === null) {
    myfolder = userhome.createFolder(Descr);
}
document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;I just have to change the red command to set it on the same folder.&lt;/P&gt;&lt;P&gt;Explaination :&lt;/P&gt;&lt;P&gt;I have the files with that metadata on share site folder alfresco\share\page\Sites\BDC\BC_INFO\&lt;/P&gt;&lt;P&gt;I need that the script create the folder in this node :&lt;/P&gt;&lt;P&gt;alfresco\share\page\Sites\BDC\BC_INFO\"Descr"&lt;/P&gt;&lt;P data-unlink="true"&gt;Again, thank you very much for you help&amp;nbsp;&lt;SPAN class=""&gt;roberto_gamiz&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 09:29:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114411#M31772</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-12-06T09:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114412#M31773</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;To execute the process in the same folder just change the line&lt;/P&gt;&lt;PRE&gt;var myfolder = userhome.childByNamePath(Descr);&lt;/PRE&gt;&lt;P&gt;for&lt;/P&gt;&lt;PRE&gt;var parent = document.parent;
var myfolder = parent .childByNamePath(Descr);&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 10:36:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114412#M31773</guid>
      <dc:creator>roberto_gamiz</dc:creator>
      <dc:date>2019-12-06T10:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114413#M31774</link>
      <description>&lt;P&gt;Thank you again to take care about me !&lt;/P&gt;&lt;P&gt;Here is the code for now :&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];
var parent = document.parent;
var myfolder = parent.childByNamePath(Descr);
if (myfolder === null) {
    myfolder = parent.createFolder(Descr);
}
document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;But script failed&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Caused by: java.lang.NullPointerException: Illegal null path&lt;/PRE&gt;&lt;P&gt;I didn't paste all the javalog to not spam, but i can if you need all logs&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 10:58:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114413#M31774</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-12-06T10:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114414#M31775</link>
      <description>&lt;P&gt;I think you need to add some integrity checks to your code.&lt;/P&gt;&lt;P&gt;For example before start the process you need to ensure that the property "test:BDC-SEDIT-propriete" have a value not equals to null and that the code is not executed for a content of folder type.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2019 12:49:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114414#M31775</guid>
      <dc:creator>roberto_gamiz</dc:creator>
      <dc:date>2019-12-06T12:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114415#M31776</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for you reply.&lt;/P&gt;&lt;P&gt;I put only files who contain&amp;nbsp;&lt;SPAN&gt;"test:BDC-SEDIT-propriete" value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And i still have the same error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I add in the alfresco's rules to not execute if the&amp;nbsp;"test:BDC-SEDIT-propriete" = null&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I still have the same error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When i use the script with this code value&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];&lt;BR /&gt;var parent = document.parent;&lt;BR /&gt;var myfolder = parent.childByNamePath(Descr);&lt;BR /&gt;if (myfolder === null) {&lt;BR /&gt;myfolder = userhome.createFolder(Descr);&lt;BR /&gt;}&lt;BR /&gt;document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;It work and move folders/files correctly on my user's folder.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We are so close to adjust it, do you think that "document.parent" is not the good command ?&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;var parent = document.parent;
var myfolder = parent.childByNamePath(Descr);&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;I just suppose because i'm not expert at all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;By advance thank you again !&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 11:04:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114415#M31776</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-12-09T11:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114416#M31777</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;You are receiving that null pointer error because you are passing a null value to the function childByNamePath.&lt;/P&gt;&lt;P&gt;I think this happens beacause the rule is executed for the subfolders that are created in the process, i'm not sure that the condition with null in the rule definition work properly in this case.&lt;/P&gt;&lt;P&gt;Try to add a condition in the rule definition for only execute the rule for documents and add the null comparation in the script code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 11:56:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114416#M31777</guid>
      <dc:creator>roberto_gamiz</dc:creator>
      <dc:date>2019-12-09T11:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: create folder with document.properties and push files into this folder</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114417#M31778</link>
      <description>&lt;P&gt;It work !!!&lt;/P&gt;&lt;P&gt;Thank you !!!!&lt;/P&gt;&lt;P&gt;I just add in the rule the condition as you expected :&lt;/P&gt;&lt;P&gt;If in the content "BDC-SEDIT-propriete" have "XXX" (XXX = number of the metadata)&lt;/P&gt;&lt;P&gt;The good java command for people who needed the same as me :&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["alah:BDC-SEDIT-propriete"];
var parent = document.parent;
var myfolder = parent.childByNamePath(Descr);
if (myfolder === null) {
    myfolder = parent.createFolder(Descr);
}
document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;To finally add some more features ine the folder's name with more metadata it look like this&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;var Descr = document.properties["test:BDC-SEDIT-propriete"];
var libelle =  document.properties["test:BDC-SEDIT-ObjetCommande"];
var tiers =  document.properties["test:BDC-SEDIT-LibelleTiers"];
var parent = document.parent;
var myfolder = parent.childByNamePath(Descr + "_" + tiers + "_" + libelle);
if (myfolder === null) {
    myfolder = parent.createFolder(Descr + "_" + tiers + "_" + libelle);
}
document.move(myfolder);&lt;/PRE&gt;&lt;P&gt;With this, the folder name look like this : "BDC-SEDIT-propriete_BDC-SEDIT-ObjetCommande_BDC-SEDIT-LibelleTiers"&lt;/P&gt;&lt;P&gt;Roberto you ownz ! if you send me private message with your postal adress i'll send you french wine ! Promise !&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 15:07:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/create-folder-with-document-properties-and-push-files-into-this/m-p/114417#M31778</guid>
      <dc:creator>castelsarrasin</dc:creator>
      <dc:date>2019-12-09T15:07:47Z</dc:date>
    </item>
  </channel>
</rss>

