Toast Messages
Toast messages, also known as popup or toast messages, are used to communicate with the users and inform them of important changes or errors that have occurred while they interact with record forms.
To set up a new toast message that is not in the "out-of-the-box" installation, you need to:
- Create a source message.
- Create message translations.
- Configure the business rule whose conditions trigger the message display.
Toast types
The following types of toasts are available on the SimpleOne platform:
Name | Description | Example |
---|---|---|
Info | The action has been completed, but there is additional information that may be useful for users. Often messages of this type are displayed with success messages. | |
Warning | The action has been completed, but there is important information that users need to know. | |
Error | The action has not been completed because an error occurred. Messages of this type are not closed automatically. | |
Success | The action has been completed. Messages of this type must always appear after a form has been successfully submitted. |
Messages of all types except errors are automatically closed after a specified period of time. The default value is 4 seconds. You can specify a different value in the durationMilliseconds
parameter that is available for methods that display messages of all types except errors.
Create a source message
All toast message texts are stored in the Source Messages (source_message) table.
To create a new toast message, complete the following steps:
- Navigate to System Localization → Source Messages.
- Click New and fill in the Message field.
- Click Save or Save and exit to apply the changes.
The text of the source message must be in English.
You can also add translations of this message to any language. See the Localization and Multi-language Support article to learn more.
Configure a business rule
To display the message when a business rule is executed, configure the following parameters when creating or updating a business rule record:
- On the Action tab, select the Add message checkbox.
- In the Message field that appears, enter the message you need. Enter the message from the Source Messages table for it to be localized.
See the Business Rules article to learn how to create and configure business rules.
Configure a script
To add a toast message with a script, open the form of a record to which the message should be connected and find the Script field. You can use variables, dynamic links and translations in the toast messages.
The list of methods that can be used in the business rule to add a message:
- s_form.addErrorMessage(message)
- s_form.addInfoMessage(message, durationMilliseconds)
- s_form.addSuccessMessage(message, durationMilliseconds)
- s_form.addWarningMessage(message, durationMilliseconds)
- ss.addInfoMessage(message, params)
- ss.addErrorMessage(message, params)
- ss.addSuccessMessage(message, params)
Examples:
(function executeRule(current, previous = null /*not null only when action is update*/) {
const iaStats = new SimpleRecord('instance_activity_stats');
iaStats.get('ci_instance', current.sys_id);
if(iaStats.sys_id){
iaStats.active = false;
iaStats.update();
ss.addInfoMessage(IAStats <a href="/record/instance_activity_stats/${iaStats.sys_id}" target="_blank"><span style="color: #0050C8;">${iaStats.getDisplayValue()}</span></a> deactivated.)
}
})(current, previous);
(function executeRule(current, previous = null /*not null only when action is update*/) {
const message = new SimpleMessage();
const localizedMessage = message.getMessage('Inherits property has been activated for global UI action');
ss.addInfoMessage(localizedMessage);
})(current, previous);