All script variables are accessible over the ctx (Context) variable. The following fields can be used.
Name | Type | Description |
---|---|---|
ctx.data | Object | The data for the content item |
ctx.dataOld | Object | The old data of the content item. Only for "Update" scripts. You can also use ctx.oldData as an alias |
ctx.operation | String | The name of the operation, as it is also used in the UI ("Query", "Create", "Update", "Delete", "Change"). In addition to that "Published" is used when the status is changed to "Published" and "Unpublished" is used when the previous status is "Published". |
ctx.status | String | The status of the content. |
ctx.statusOld | String | The old status of the content item. Only for "Change" scripts. You can also use ctx.oldStatus as an alias. |
ctx.contentId | String | The ID of the content item. |
ctx.appId | String | The ID of the current app. |
ctx.appName | String | The name of the current app. |
ctx.user | Object | Information about the current user. See the table below for more information. |
The User Object has the following structure:
Field | Type | Description |
---|---|---|
ctx.user.id | String | The ID of the user or the name of the client, if the update or query is invoked from a client. |
ctx.user.email | String | The email address of the user if the user is not a client. |
ctx.user.isClient | Boolean | True, if the current user is a client, false otherwise. |
ctx.user.claims.xxx | String | Each user has a list of claims. Claims are just key-value-pairs. For example, a claim could be the display name of the user or the link to the profile picture. Most of them are not useful for scripting, but you can also go to your profile and add custom properties as claims to your account and use them in the scripts or rules. |
Comments
Let us know what was helpful or not helpful about the article.0 comments
Please sign in to leave a comment.