Hi All,
I am writing rule for moving document created inside folder to a new folder hierarchy created dynamically through cm:created. Now i only want documents created inside folder to be only moved not subfolders which are already there.
Could anyone told what i am doing wrong with code:-
var createdDate = document.properties["cm:created"]; var scanId = document.properties["live:uniqueDocument"]; var date = new Date(createdDate); var year = ""+date.getFullYear(); var month = ""+(date.getMonth()+1); var day = ""+date.getDate(); var hour = ""+date.getHours(); var min = ""+date.getMinutes(); var formattedDate = year+"-"+month+"-"+day; var calender = [year,formattedDate,day,hour,min]; var parent = document.parent; for(var i =0; i<calender.length;i++) { var myfolder = parent.childByNamePath(calender[i]); if (myfolder === null) { myfolder = parent.createFolder(calender[i]); } parent = myfolder; } document.move(myfolder);
Thanks and Regards,
Piyush
Solved! Go to Solution.
Try document.getType() method to get the type in combination to isSubType check as suggested already.
https://docs.alfresco.com/content-services/6.2/develop/reference/repo-root-objects-ref/
Get type method options:
Likely nothing wrong with your code but your rule configuration. Make sure to restrict your rule to only trigger on content nodes, not folder nodes. Alternatively, you could of course include a 'document.isSubType("cm:content")' check in your code and only act if that is the case.
Hi @afaust ,
Thanks it was working fine but it is moving all the documents created. i want to move document for my custom type only. I am trying to get type through this:-
var nodeType = document.properties["cmisbjectTypeId"];
i think i am using wrong approach for getting type.
Please do help me out.
Thanks,
Piyush
Try document.getType() method to get the type in combination to isSubType check as suggested already.
https://docs.alfresco.com/content-services/6.2/develop/reference/repo-root-objects-ref/
Get type method options:
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.