Condition in an automation chain
Hi, How can I use some sort of conditional statement in the automation chain? I want to create a document under the private workspace of an user only if it wasn't created before.
Thank you!
Assuming you are doing that in Nuxeo-Studio:
Start by creating 2 operations:
The first of type: “Document > Create”, let's call it
CREATE_MY_DOC
.You could supply here a document path as a parameter of your expected/existing document.
The second of type: “User Interface > Add Info Message”, let's call it
NOTIFY_DOCUMENT_EXISTS
.This is just an example, you could use a void operation instead.
Then create your “logic” operation of type: “Execution Flow > Run Operation”
Give this operation an ID of the following form: (condition?op1:op2)
where if the “condition” is true, then “op1” is executed, otherwise “op2”
In the condition statement you can check if your document exists, for instance using NXQL:
@{(Session.query("SELECT * FROM Document WHERE ecm:path='MY_PATH").size()==0?"CREATE_MY_DOC":"NOTIFY_DOCUMENT_EXISTS")}
This should launch the appropriate operation creating the document if, and only if, it does not yet exist.