Nuxeo Server

How to Inherit Metadata from a Parent Document

Updated: November 13, 2017 Page Information Edit on GitHub

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 creation context of a document to infer some metadata values. For example, you can set a project_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 allow the setting of 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. If 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 Handler (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
- Context.PushDocument
- Document.GetParent:
    type: Workspace
- Context.SetVar:
    name: sourceValue
    value: "@{Document[\"dc:source\"]}"
- Context.PopDocument
- Document.SetProperty:
    xpath: "dc:source"
    save: "true"
    value: "@{sourceValue}"

4 days ago manonlumeau Added content-review-lts2017 label
a month ago manonlumeau NXDOC-1346-FT review screenshot
2 years ago Manon Lumeau 28
2 years ago Manon Lumeau 27
3 years ago Solen Guitter 26
3 years ago Solen Guitter 25
3 years ago Solen Guitter 24 | Add related links
3 years ago Solen Guitter 23
3 years ago Solen Guitter 22
4 years ago Alain Escaffre 21
4 years ago Alain Escaffre 19
4 years ago Alain Escaffre 20
7 years ago Solen Guitter 17 | typo
7 years ago Solen Guitter 18
7 years ago Solen Guitter 16
7 years ago Solen Guitter 15 | Added link and reorganized instructions
8 years ago Alain Escaffre 14
8 years ago Alain Escaffre 13
8 years ago Alain Escaffre 12
8 years ago Alain Escaffre 11
8 years ago Alain Escaffre 10
8 years ago Alain Escaffre 9
8 years ago Alain Escaffre 8
8 years ago Alain Escaffre 7
8 years ago Alain Escaffre 6
8 years ago Alain Escaffre 5
8 years ago Alain Escaffre 3
8 years ago Alain Escaffre 4
8 years ago Alain Escaffre 1
8 years ago Alain Escaffre 2
History: Created by Alain Escaffre