Platform Explorer / Nuxeo Platform 5.6

Operation Document.SetProperty

Update Property

Description

Set a single property value on the input document. The property is specified using its xpath. The document is automatically saved if 'save' parameter is true. If you unset the 'save' you need to save it later using Save Document operation. Return the modified document.
  • 5.7.2
  • 5.6
  • 5.7-I20130322_1136

Here’s some examples of how to use this operation :

  1. Fetch > Context Document
  2. Execution Context > Set Context Variable
  3. Document > Update Property
    • value=@{CurrentDate.days(7).date}
    • xpath=dc:expired
    • save: unchecked
  4. Document > Update Property
  5. Document > Update Property
    • value=@{"TICKET-"+Fn.getNextId("TICKET")}
    • xpath=uid:uid
    • save: checked
  6. Document > Update Property
  7. User & Groups > Logout

Step 3 shows how to update a property of a Date Type element of a schema (here dublincore expired). Here we’ve decided that the document will have an expiration date set in seven days starting from the current date.

Step 4 reuses a context variable we already set before at step 2.

Step 5 shows how you can use scripting features of Nuxeo Studio like using functions, and concatenate two strings. The objective of this operation will be to generate a unique identifier that will match this pattern : TICKET-0001

Step 6 is a simple example of updating a field in a static way.

Please note that we checked "save" for the last update property operation only.

Other examples can be found here:

Operation id Document.SetProperty
Category Document
Label Update Property
Requires
Since

Parameters

Name Description Type Required Default value
value serializable yes  
xpath string yes  
save boolean no true 

Signature

Inputs document, documents
Outputs document, documents

Implementation information

Implementation class org.nuxeo.ecm.automation.core.operations.document.SetDocumentProperty
Contributing component BuiltIn

JSON definition

{
  "id" : "Document.SetProperty",
  "label" : "Update Property",
  "category" : "Document",
  "requires" : null,
  "description" : "Set a single property value on the input document. The property is specified using its xpath. Save parameter automatically saves the document in the database. It has to be turned off when this operation is used in the context of the empty document created, about to create, before document modification, document modified events. Returns the modified document.",
  "url" : "Document.SetProperty",
  "signature" : [ "document", "document", "documents", "documents" ],
  "params" : [ {
    "name" : "xpath",
    "description" : "",
    "type" : "string",
    "required" : true,
    "widget" : null,
    "order" : 0,
    "values" : [ ]
  }, {
    "name" : "save",
    "description" : "",
    "type" : "boolean",
    "required" : false,
    "widget" : null,
    "order" : 0,
    "values" : [ "true" ]
  }, {
    "name" : "value",
    "description" : "",
    "type" : "serializable",
    "required" : false,
    "widget" : null,
    "order" : 0,
    "values" : [ ]
  } ],
  "widgets" : [ {
    "name" : "xpath",
    "type" : "codearea",
    "labels" : {
      "any" : "XPath"
    },
    "translated" : true,
    "handlingLabels" : false,
    "fields" : [ {
      "fieldName" : "xpath",
      "propertyName" : "xpath"
    } ],
    "properties" : {
      "any" : {
        "height" : "100%",
        "language" : "xpath",
        "width" : "100%"
      }
    }
  } ]
}