Automation

How to Inherit a Metadata from a Parent Document

There are cases where you want a document to inherit some metadata values from its parent. In general, the goal is to benefit from the context of creation of a document to infer some metadata values. For instance, you can set a projet_id metadata on your document type and on the workspace (or any type of container). Then your document type can inherit the project id value from its parent workspace. This is also useful when most of your documents are captured via Nuxeo Drive. Since Drive doesn't enable to set metadata values, you can only infer them from parent containers.

In this how-to, we will implement an event handler, that will listen to the creation of documents. When the created document matches some predefined criteria, the listener will execute a content automation chain. The chain will copy the Dublincore "source" metadata value from the workspace to the created document.

To maintain inheritance, you need to use the event "Document Updated" and select the children document you want to update. This approach would work with a few documents below your parent documents only. For a larger number of documents, you should  consider a lower level approach.

Prerequisite

To complete this how-to, you need the elements below to be already configured in your Nuxeo Studio project.

Creating the Event Handler

To implement the metadata inheritance listener:

  1. Create a new Event Handlers (see how to bind an automation chain to an event handler).
  2. Fill in the filtering information below:
    • Events: Document created
    • Current document has one of the types: DocumentationItem
  3. Create the corresponding automation chain (see below for the chain parameters).

Creating the Automation Chain

Create an automation chain with the following operations and parameters:

- Context.FetchDocument
- Document.Push
- Document.GetParent:
    type: Workspace
- Context.SetVar:
    name: sourceValue
    value: "@{Document[\"dc:source\"]}"
- Document.Pop
- Document.SetProperty:
    xpath: "dc:source"
    save: "true"
    value: "@{sourceValue}"

 


4 months ago manonlumeau Relocated assets to fit new URL structure for 710 - fix
4 years ago Manon Lumeau 28
4 years ago Manon Lumeau 27
5 years ago Solen Guitter 26
5 years ago Solen Guitter 25
5 years ago Solen Guitter 24 | Add related links
5 years ago Solen Guitter 23
5 years ago Solen Guitter 22
5 years ago Alain Escaffre 21
5 years ago Alain Escaffre 19
5 years ago Alain Escaffre 20
9 years ago Solen Guitter 17 | typo
9 years ago Solen Guitter 18
9 years ago Solen Guitter 16
9 years ago Solen Guitter 15 | Added link and reorganized instructions
9 years ago Alain Escaffre 14
9 years ago Alain Escaffre 13
9 years ago Alain Escaffre 12
9 years ago Alain Escaffre 11
9 years ago Alain Escaffre 10
9 years ago Alain Escaffre 9
9 years ago Alain Escaffre 8
9 years ago Alain Escaffre 7
9 years ago Alain Escaffre 6
9 years ago Alain Escaffre 5
9 years ago Alain Escaffre 3
9 years ago Alain Escaffre 4
9 years ago Alain Escaffre 1
9 years ago Alain Escaffre 2
History: Created by Alain Escaffre

We'd love to hear your thoughts!

All fields required