Implement document validation chain

Updated: August 19, 2019

We want people from the group "validators" to be able to change the lifecycle state of the document to "valid". When doing this, we expect some actions to be automatically run:

  • Storing the date of validation on the document itself, in dc:valid metadata;
  • Storing a pdf transformation of the file on the document itself, so that users don't have to rely on the dynamic transform service to get the file (this will be needed too when we will make the document go from "revision" state back to "valid");
  • Storing on the document the version of the module at the time the document is validated, so that we always know for which version of the module the document was relevant.

Validation action will be displayed as an icon on the contextual actions of the document, on the right upper side of the screen, beside print, email and zip export actions. Here is the result of the validation we want to achieve on the document's metadata:

To implement the validation chain:

  1. Declare the action by clicking on User Actions in the Studio tree (see also how to create a new action).
  2. Fill in the filtering information. In our sample, we want to display the button when the following conditions are met:
    • the current document is of type "DocumentationItem",
    • it is a regular document
    • its lifecycle is "draft"
    • the user is a member of the group "validators":
  3. Create the corresponding automation chain. As we need to reuse the conversion of the content:file blob into pdf and storing of it as a blob in pdf_version field when we make the document go from "revision" back to "valid", we actually create two chains here:
    • a PDF conversion chain,
    • a validation chain, that executes the PDF conversion chain at some point. See below for each chain configuration.
The pdf conversion subchain parameters

Operation

Parameter 1

parameter 2

1

Fetch > Context Document

_

_

2

Push and Pop > Push Document

_

_

3

Files > Get Document File

xpath: file:content

_

4

Files > Convert to pdf

_

_

5

Context > Set variable from input

name: pdf

_

6

Push and Pop > Pop Document

_

_

7

Document > Set File

file: expr:pdf

xpath: pdf_version

The input and output of some of the operations (3,4,5) handles a different type: "Blob". If you don't order well the elements, it will alert you by coloring the operation in red. See the Operation flow - input and output typing page.

The validation chain parameters

Operation

Parameter 1

parameter 2

1

Fetch > Context Document

_

_

2

Document > Follow lifecycle transition

value: validate

_

3

Chain execution > Run document chain

id: SetPDFVersionChain

_

4

Document > Update property

value: expr:CurrentDate.date

xpath: dc:valid

5

Push and Pop > Push Document

_

_

6

Document > Get Parent

type: Module

_

7

Context > Set context variable

name: module_version

value: expr:Document["module:module_version"]

8

Push and Pop > Pop Document

_

_

9

Document > Update property

value: expr:module_version

xpath: documentationitem:first_module_version

In Validation chain step 3 we call the subchain that operates the PDF conversion.

We'd love to hear your thoughts!

All fields required