create folder with document.properties and push files into this folder

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

Re: create folder with document.properties and push files into this folder

Jump to solution

Hello,

You are receiving that null pointer error because you are passing a null value to the function childByNamePath.

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.

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. 

Regards

castelsarrasin
Active Member II

Re: create folder with document.properties and push files into this folder

Jump to solution

It work !!!

Thank you !!!!

I just add in the rule the condition as you expected :

If in the content "BDC-SEDIT-propriete" have "XXX" (XXX = number of the metadata)

The good java command for people who needed the same as me :

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);

 

To finally add some more features ine the folder's name with more metadata it look like this 

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);

With this, the folder name look like this : "BDC-SEDIT-propriete_BDC-SEDIT-ObjetCommande_BDC-SEDIT-LibelleTiers"

 

Roberto you ownz ! if you send me private message with your postal adress i'll send you french wine ! Promise !