reference1 min readApplication: Platform
ApplicationPropertyManager
Methods of ApplicationPropertyManager, which reads and creates application properties and returns the instance's base URL and ID in server scripts.
ApplicationPropertyManager is the global that reads application properties in server scripts. It also creates property records and returns the instance’s base URL and ID. Client scripts read properties marked Client side accessible through User.getProperty() instead, as described in user and User.
Get an instance
ApplicationPropertyManager is ready to use.
let timezone = ApplicationPropertyManager.getProperty("system.timezone");
Methods
| Method | Returns | Description | Since |
|---|---|---|---|
getProperty(key) |
String | The property’s value, or null when it does not exist. | 1.11 |
getProperty(key, default) |
String | The property’s value, or default when it does not exist. |
1.11 |
getBooleanProperty(key) |
Boolean | The value as a boolean, or false when it is empty or does not exist. | 1.11 |
getBooleanProperty(key, default) |
Boolean | The value as a boolean, or default when it is empty or does not exist. |
1.11 |
getIntegerProperty(key, default) |
Number | The value as a whole number, or default when it is empty or does not exist. A value that is not a number raises an error. |
1.11 |
getGlobalPropertyRecordByKey(key) |
TableRecord | The property’s record, or null when it does not exist. Update the record to change the value. | 1.11 |
createGlobalPropertyRecord(key, value, dataType, description) |
TableRecord | Creates a property record, for example with dataType "string". |
1.11 |
getBaseUrl() |
String | The instance’s base URL, the system.baseurl property. |
1.11 |
generateDefaultBaseUrl() |
String | The base URL the instance would use with no system.baseurl set. |
1.11 |
getInstanceID() |
String | The ID of this instance. | 1.11 |
Examples
Read properties with defaults
Servicely Script
[
ApplicationPropertyManager.getProperty("system.currency", "USD"),
ApplicationPropertyManager.getBooleanProperty("system.multilingual", false),
ApplicationPropertyManager.getIntegerProperty("system.job.queue.pool.size.limit", 50)
];
Response
["USD", false, 50]
Create a property or change its value
let key = "system.baseurl";
let record = ApplicationPropertyManager.getGlobalPropertyRecordByKey(key);
if (record == null) {
ApplicationPropertyManager.createGlobalPropertyRecord(
key,
"https://<your URL>",
"string",
"The base URL to use for URL construction"
);
} else {
record.Value("https://<your URL>").update();
}