Tutorial

Editing pages

As cplace.actions().updatePage and cplace.actions().deletePage are functions with side effects they can only be used in scripts with the actions feature enabled, otherwise an error will be raised.

Table of contents
  1. Basic usage
  2. Unsetting attributes
  3. Deleting a page

Basic usage

The basic usage of updatePage(page, data, options) does not differ much from the createPage(data, options) function, except you have to provide a page object for it to update and you leave out the space and customType properties as the page already exists in a space and it's usually not a good idea to change a page's type.

Furthermore the provided PageData object just contains the delta to the current state of the page, i.e. if you change a single attribute only it would look like that:

cplace.actions().updatePage(page, {
    customAttributes: {
        'cf.cplace.assignee': cplace.utils().getCurrentUser()
    }
});

Unsetting attributes

When updating a page you can unset custom attributes by setting it to null like in the following example:

cplace.actions().updatePage(page, {
    name: 'New name',
    customAttributes: {
        'cf.cplace.value': 100,
        'cf.cplace.assignee': null
    }
});

This will change the name of the page to "New name", set the value to 100 and unset the assignee attribute.

Deleting a page

It is not only possible to change pages in cplaceJS, but also to delete them completely. To do so provide the page to delete to the deletePage action:

cplace.actions().deletePage(page);