Class

PlatformActions

PlatformActions

cplaceJS actions provided by platform

Note:

  1. Actions will be executed with write permissions checks suppressed
  2. All builtin attributes will be referred by their feature names
  3. All references must be provided as Uids or as entities.

Methods

createPage(data, optionsopt) → {Page}

Creates a page in the context of user executing the script with provided data and options. For creating a page at least name, customType and space must be provided. If the custom type supports name generation, then the name property can be omitted, but an options opbject with setGeneratedName set to true must be provided.

Parameters:
Name Type Attributes Description
data PageData

Information and data that will be applied upon creation

options PageOptions <optional>

Additional options to use when creating the page

The newly created page.

Page
Examples
var page = cplace.actions().createPage({
     name: 'Test page'
     space: 'pageSpace/iogef7klu9wjdj4l63ne4iyie',
     customType: 'my.custom.type',
     customAttributes: {
         attr1: 'value1',
         attr2: 42,
         attr3: true,
         attr4: ['red', 'green'],
         attr5: 'page/uidofsomepage'
     },
     readers: ['person/uid of person', 'group/uid of group']
});
// For setting permissions we provide an extended API as follows:
// Inherit permission from parent. <b>inherited</b> string can be used indicate that this permission should be inherited from its parent.

{
     ...
     readers: 'inherited'
     ...
}
// Set permission explicitly. The values must be provided as an array and must only contain either Uids or instance of person/group

{
  ...
  writers: ['person/uid1', 'group/uid2']
  ...
}
// Add/remove permissions seamlessly

{
  ...
  writers: {
     'additiveInheritance': true,
     '+': [uids...],
     '-': [uids...]
  }
  ...
}
// To find specific users and groups following utility methods can be used

cplace.utils().findUserByLogin('email@user'); // returns user with email 'email@user', if exists.
cplace.utils().findGroupByName('developers'); // returns group with name 'developers', if it exists.
cplace.utils().getAllUsersGroup(); //returns group representing all registered users of cplace.

deletePage(page)

Delete a given page.

Parameters:
Name Type Description
page Page

The page to delete

Example
cplace.actions().deletePage(page)

refresh()

Reloads the current page. The script after the refresh action will still be executed, before the reload actually happens.

sendMail(data)

Send an email.

Parameters:
Name Type Description
data SendMailData

information to use sending the mail.

Example
var accepted = true;
var mailtopic = "your latest plan";

cplace.actions().sendMail({
    fromAddress: 'max.meier@test.com',
    fromName: 'Max Meier',
    to: 'ernst.haft@test.com',
    subject: 'About $topic$',
    message: 'Hello $name$, this is about $topic$. It is$[condition$ accepted$]condition[$ denied$condition]$! Regards, Max',
    substitutions: {
        name: 'Ernst',
        topic: mailtopic,
        condition: accepted
    }
});

sendNotification(data)

Dispatches a user notification which will be visible to addressed users immediately.

Parameters:
Name Type Description
data NotificationOptions

Options to use for creating the notification.

Example
cplace.actions().sendNotification({
    message: {
        de: 'Der Kuchen ist ein Schwindel!!',
        en: 'The cake is a lie!'
    },
    title: {
        de: 'Achtung',
        en: 'Attention'
    },
    icon: 'fa-birthday-cake',
    isCritical: true,
    recipients: 'systemGroup/allusers'
});

updatePage(page, data, optionsopt)

Update a page with provided data and options. This method will not change the persistent state of the page entity.

Parameters:
Name Type Attributes Description
page Page

page that has to be updated

data PageData

information that will be used to update the page.

options PageOptions <optional>

options to use when updating page

Example
cplace.actions().updatePage(page, {
     layoutName: 'layoutType2',
     customAttributes: {
         attr2: null, // setting null explicitly removes the value
         attr3: false,
         attr4: ['yellow']
     }
}, {
  setGeneratedName: true
});