content.modifyΒΆ

This command modifies a content.

key (string)
Path or id to the content.
editor (function)
Editor callback function.
branch (string)
Set by portal, depending on context, to either “draft” or “master”. May be overridden, but this is not recommended. Default is the current branch set in portal.

Example:

function editor(c) {
    c.displayName = 'Modified';
    c.data.a++;
    c.data.z = '99';

    c.x['other'] = {
        name: 'test'
    };

    return c;
}

var result = execute('content.modify', {
    key: '/my/content',
    editor: editor
});

if (result) {
    log.info('Content modified. New title is ' + result.displayName);
} else {
    log.info('Content not found');
}

Result:

{
  "_createdTime": "1970-01-01T00:00:00Z",
  "_creator": "user:system:admin",
  "_id": "123456",
  "_modifiedTime": "1970-01-01T00:00:00Z",
  "_modifier": "user:system:admin",
  "_name": "mycontent",
  "_path": "/a/b/mycontent",
  "data": {
    "a": [2.0],
    "b": ["2"],
    "c": [
      {
        "d": ["true"]
      },
      {
        "d": ["true"],
        "e": [
          "3",
          "4",
          "5"
        ],
        "f": ["2"]
      }
    ],
    "z": ["99"]
  },
  "displayName": "Modified",
  "draft": false,
  "hasChildren": false,
  "x": {
    "mymodule": {
      "myschema": {
        "a": ["1"]
      },
      "other": {
        "name": ["test"]
      }
    }
  },
  "page": {},
  "type": "system:unstructured"
}