简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM