Automation chain to log audit event to two documents

I'm working on an automation chain that is called by an action button. The button makes a copy of the context document and assigns some new properties to the copy.

I want the automation chain to log an event (Audit.LogEvent) to the context document, and log an event to the new document created by the copy button. The chain successfully logs an event for the context document, but I'm struggling with how to get the chain to “find” the copy document so the following Audit.LogEvent can log an event to it.

Below is a simplified pseudocode version of the YAML for the chain, with the question mark representing where the copied document should be fetched.

params:
  - recNumber:
      type: string
  - oldRecNumber:
      type: string
operations:
  - Context.FetchDocument
  - Audit.LogEvent:
      event: Log to source document
      category: Automation
      comment: Document.name copied from oldRecNumber to recNumber
  - ?
  - Audit.LogEvent
      event: Log to copy document
      category: Automation
      comment: Document.name copied from oldRecNumber to recNumber

I'm unsure if the best way of getting the copy document is using Repository.Query or Document.FetchByProperty, and I haven't been able to find any really good examples of either one.

Any ideas would be appreciated.

0 votes

1 answers

137 views

ANSWER



Hello,

Using automation scripting is way easier in this context as you can store documents and variables, and it becomes simple to execute operation on each documents.

You should have a look at this code https://github.com/nuxeo/nuxeo-studio-community-cookbook/blob/master/modules/nuxeo/copy-move/modeler/AS_Copy.js and the component which was developed

Regards

0 votes