Toast PopUp - Advanced Options
Change Type
|
Description
|
Version Number
|
Enhancements
|
-
Advanced options added to allow Toast functionality without using the Toast control (greater flexibility in functionality).
|
4.5.32
|
The Toast Controls provide some basic functionality in the creation and display of toasts. JavaScript can be used to provide further flexibility to Toasts if required, for example, to display Toasts on a conditional basis.
It is recommended that any code is placed in a JavaScript control to run on page load, or to call at specific points on the script page (rather than a Calculate field which will keep firing, hence users will end up with duplicate toasts appearing.).
When coding a toast can be displayed by calling the Show function:
Script.Toast.Show(text, type, title, duration, closeable, name);
Name
|
Required/Optional
|
Explanation
|
Text
|
Required
|
The text to display in the body of the toast
|
Type
|
Optional
|
The type of toast to display (Script.Toast.Type.Script.Toast.Type.Error, Script.Toast.Type.Success, Script.Toast.Type.Information, Script.Toast.Type.Warning or Script.Toast.Type.Loading)
|
Title
|
Optional
|
The title to use within the toast. Blank if not supplied.
|
Duration
|
Optional
|
The time in milliseconds to display the toast for. Defaults to 5000 (5 seconds). Specify 0 to leave open until user closes it.
|
Closeable
|
Optional
|
true or false. Specifies whether the user is able to manually close the toast. Defaults to true.
|
Name
|
Optional
|
Provide a unique name to be able to refer back to at a later date (eg, to remove it). The name is returned from the Show function. If a name is not specified one is generated automatically.
|
Example:
Since many of these arguments are optional, there is an alternative syntax where the user only needs to specify the paremeters required, for example:
Script.Toast.Show({
text: 'Hello World',
title: 'Test',
duration: 10000
});
Note that variables and fields will not automatically be expanded from within the parameters, unlike in the
Script Labels, allowing a toast's content to change, rather you have to build up the text and pass it in the parameter, ie this will work:
Script.Toast.Show({
text: 'Caller name is: ' + [var_callername]
});
Whilst this will not:
Script.Toast.Show({
text: 'Caller name is: [var_callername]'
});
Hiding a Toast
As well as the user closing a toast, you can also do so programmatically, using the Hide function:
Script.Toast.Hide(name);
where name is the name given to/returned from the Show function, above.