06-01-2021 01:57 AM
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
06-03-2021 10:44 AM
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:
06-01-2021 06:45 AM
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.
06-03-2021 07:55 AM
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
06-03-2021 10:44 AM
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:
Explore our Alfresco products with the links below. Use labels to filter content by product module.