Datamodel currently saved on the server.
Note that when you access this inside a callback of Api.subscribeFor, the datamodel already contains the corresponding changes
Allows performing Http(s)-calls to third-party REST APIs.
Api for the metamodel.
Api for managing surveys
Api for accessing user information
Api for accessing user group information
Create a date that can be set as attribute value or can be used within date intervals.
Number of milliseconds since Jan 01 1970 (UTC) Only use this to create date objects if you want to assign them to building blocks.
Create a date that can be set as attribute value or can be used within date intervals.
String representation supported by new Date()
(eg. 'October 3, 2018 17:34:00' or '2018-10-03T17:34:00')
For exact documentation of the supported formats see
https://docs.oracle.com/javase/8/docs/api/java/util/Date.html#parse-java.lang.String-
Create a date that can be set as attribute value or can be used within date intervals.
Year of the date
Month of the date (indexed from 0 to 11)
Day of the month (starting at 1)
Hour of the day
Minutes of the hour
Seconds of the minute
Milliseconds of the second
Get history for Building Block.
Id of the building block
Persistent name of the type of the building block type
Get history for Building Block Type.
Persistent name of the building block type for which the history should be returned
Gets inner properties of Building Block attribute by its persistent name (mandatory, multiple and type attribute properties are available)
Type of the building block
Persistent name of the property
var propertyInfoObject = api.getPropertyInfo("Project", "Accountability");
// Create the string to be logged
var propertyInfo = 'Project - Accountability '
+ '(type: ' + propertyInfoObject.type
+ ', multiple: ' + propertyInfoObject.multiple
+ ', mandatory: ' + propertyInfoObject.mandatory + ')';
// log the information
api.printLog(propertyInfo);
Register a callback function which gets called when the script is specifically executed.
Function to run when executing this script
This and Api.subscribeFor are the only two functions that should be called at the top level scope of a plugin script.
If this is called in a Api.subscribeFor callback, it will reject all changes to the datamodel that caused the callback. The script will exit immediately. A corresponding error message will be shown to the user who triggered the change. If this change was caused from the REST API, the error message will be returned as response.
Optional
message: stringOptional message to be displayed to the user who triggered the change
This is only intended for usage in callbacks for Api.subscribeFor! Do not use it in callbacks to Api.registerExecution, as this might have unintended side effects.
Sends emails as a plain text. Returns an integer value of 1 if email was sent successfully, -1 if not.
Please see the Subscriptions for more information on how to configure Mail-notifications. // TODO: Delete or specify
Email address of recipient
Subject of the email
Plain text content of the email
Subscribes for changes at a Building Block Type. More than one function can subscribe for a certain Building Block Type. The system will call the function for each of these subscriptions.
Type of the building blocks for which to listen to changes
Callback called when a change occurs
This and Api.registerExecution are the only two functions that should be called at the top level scope of a plugin script.
api.subscribeFor('ItService', test);
// This comment is necessary for autocompletion in the editor to work.
// You dont need it for the script itself to work.
/**
@param {BuildingBlockType} bbt
@param {ChangeEvent} ev
*/ (Note: Remove the \ here)
function test(bbt, ev) {
for (var i = 0; i < ev.length; i++) {
var e = ev[i];
if (e.changeType === 'DELETE') {
var bb = api.datamodel.findByTypeAndId(bbt, e.id);
}
}
}
Api accessible in all plugin scripts