Toast PopUp - Advanced Options
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);
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 ToastAs 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.
|