content.createΒΆ

This command creates a content.

name (string)
Name of content.
parentPath (string)
Path to place content under. Default is ‘/’.
displayName (string)
Display name. Default is same as <name>.
requireValid (boolean)
The content has to be valid to be created. Default is (true).
contentType (string)
Content type to use.
data (object)
Actual content data.
x (object)
eXtra data to use.
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:

var result = execute('content.create', {
    name: 'mycontent',
    parentPath: '/a/b',
    displayName: 'My Content',
    draft: true,
    contentType: 'system:unstructured',
    data: {
        a: 1,
        b: 2,
        c: ['1', '2'],
        d: {
            e: {
                f: 3.6,
                g: true
            }
        }
    },
    x: {
        test: {
            a: 1
        }
    }
});

log.info('Content created with id ' + result._id);

Result:

{
  "_id": "123456",
  "_name": "mycontent",
  "_path": "/a/b/mycontent",
  "data": {
    "a": [1],
    "b": [2],
    "c": [
      "1",
      "2"
    ],
    "d": [
      {
        "e": [
          {
            "f": [3.6],
            "g": [true]
          }
        ]
      }
    ]
  },
  "displayName": "My Content",
  "draft": true,
  "hasChildren": false,
  "x": {
    "mymodule:": {
      "test:": {
        "a": [1]
      }
    }
  },
  "page": {},
  "type": "system:unstructured"
}