Updating document properties once the folder is updated

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

Updating document properties once the folder is updated

Jump to solution

Dear All,

In our test case, we got the following demand:

  • Documents are stored in specific folders.
  • Most of the document custom properties are managed on folder level in order to limit the update to be done by the user. Bascially we write the custom property value on the folder level at creation, then created a rule which applies these properties on the document when the document is added to the folder.

The above work well at document creation. However, during the process, some of the folder level properties are updated. The new values should be pushed down to all documents present in that folder.

The idea would be to get the ID of the folder, then check all child objects belonging to the selected folder and update the properties.

Does any one of you know how to do this?

Thanks alot for your help,

Zsolt Putnoky

1 Solution

Accepted Solutions
Highlighted
Established Member

Re: Updating document properties once the folder is updated

Jump to solution

SOLVED !!

Here is the solution:

Found the script to iterate through a node and its childs here: https://community.alfresco.com/docs/DOC-5716-iterate-nodes

Found a comment about the possibility to run a script stored in the Repository/Scripts folder. This option is missing from 5

.2, so we modified the config file to allow this.

Then, modified the iterating script to

  • get the properties of the node on which the action is run,
  • iterate through all child nodes
  • check the type of each child
  • if the type is set to a predefined one - this one is done via a rule applied on the folder when the user is uploading the document - then update the properties of the document with the ones from the folder
  • save the document
  • write a log file

Zsolt Putnoky

View solution in original post

4 Replies
Highlighted
Established Member

Re: Updating document properties once the folder is updated

Jump to solution

Hello Zsolt,

This shouldn't be very complicated. Could you share your code base? Or at least say which API you are using.

The concept is that you get all Children NodeRefs from your folder NodeRef. Then maybe you'll need to be recursive depending on the level you want to obtain.

Best regards

Highlighted
Established Member

Re: Updating document properties once the folder is updated

Jump to solution

Hi Simon,

Now, here is the trick, I do not have any codebase. Honestly telling you, I have no idea where to start.

So far with the help of this forum and google we managed to create the templates, modify the view, search, start up email and LDAP, etc. And reached a roadblock with the issue I mentioned. In our case, we use the folder as a container, each document in a folder belongs to the same 'object', hence it should inherit all the properti values set on the folder level. With rules and JS this is okay when the user uploads the documents into the folder. However at a certain stage in our process, the folder properties are updated and this update shall be sent down to the documents.

Do you know where I can find documentation about the different APIs? to know how to get the ID of the selected folder? and check all child objects? that would be a great help already.

Thanks alot,

Zsolt Putnoky

Highlighted
Established Member

Re: Updating document properties once the folder is updated

Jump to solution

SOLVED !!

Here is the solution:

Found the script to iterate through a node and its childs here: https://community.alfresco.com/docs/DOC-5716-iterate-nodes

Found a comment about the possibility to run a script stored in the Repository/Scripts folder. This option is missing from 5

.2, so we modified the config file to allow this.

Then, modified the iterating script to

  • get the properties of the node on which the action is run,
  • iterate through all child nodes
  • check the type of each child
  • if the type is set to a predefined one - this one is done via a rule applied on the folder when the user is uploading the document - then update the properties of the document with the ones from the folder
  • save the document
  • write a log file

Zsolt Putnoky

View solution in original post

Highlighted
Senior Member

Re: Updating document properties once the folder is updated

Jump to solution

Glad you sorted it out. Thanks for coming back to let us know!