user6286483
user6286483

Reputation:

Alfresco JavaScript, set custom type property, when file is uploaded to site

I would like to write a JavaScript script that can set a sequence number property of a document automatically, when it's type is changed to my custom type. The sequentNum property must be different from the other document's sequentNum property.

How can i get the document, and how can i set its property?

Thank you in advance for your answers!

Upvotes: 0

Views: 404

Answers (1)

Heiko Robert
Heiko Robert

Reputation: 2707

Take a look into Policies and Behaviors. You can register a JavaScript which will be executed on "OnSetNodeTypePolicy". Jeff Potts created a great Tutorial you should take a look into: Re-implementing the behavior in JavaScript

Be careful how to implement the logic for your sequence next value. Don't use search since it doesn't guarantee latest value. We used a separate node for that issue in a very early implementation where we set a maxSequence property but now we use a custom service for that approach (multithrading, scalability).

Hint: If you don't already know: You can put your xxx-context.xml Sprint bean config into tomcat/shared/classes/alfresco/extension/ instead of creating an amp file to make it easier for quick tests

Upvotes: 3

Related Questions