The button control can perform a number of actions; ok, back, macro, exit, restart or save. The action that the button performs at runtime is set via the 'buttontype' property.
Some actions need multiple control properties to be set, for example a 'buttontype' of exit employs an additional 'exitcheck' control property. Any number of button controls can be added to a Dialog by clicking and dragging the button icon from the dialog toolbar on to the editor.
A 'buttontype' of ok will attempt to leave the dialog at runtime assuming all obligatory controls (questions where 'Allow blank' = false) have values and all the values provided are valid.
A 'buttontype' of back will attempt to step back to the previous dialog.
A 'buttontype' of macro allows the developer to attach a script object to a button, this gives the developer freedom to implement all sorts of functionality such as a database lookup based on an input control on that dialog. The 'macro' property needs to be set to a script object and the 'macroautook' property set to either true or false (if true then this issues an ok action immediately after the script object completes) and optionally the 'macroparamter' property set to a value if the script object calls for a parameter. Should the attached script update objects that are shown on the current dialog, either as captured values or embedded within text, then these will also update the screen display.
A 'buttontype' of exit allows the user to exit the application, and employs an additional 'exitcheck' control property which if set to true will prompt the user to check if they really wanted to exit the application, if set to false then there is no additional check and the application will end.
A 'buttontype' of restart simply allows the user to restart the session from the beginning, losing all captured values in the process.
A 'buttontype' of save allows the user to save the state of the current session for later resumption. This action needs the 'macro' property to be set to a script object. The property xpertrule.saveSessionURL gives the developer the ability to access the saved session URL and either display it to the user or possibly include it in an email sent to the user. The following example code retrieves the saved session URL and displays this in a message after which the browser window is closed.
xpertrule.message(xpertrule.saveSessionURL, 'Saved Session URL', 'End Session');
window.close();
Here is the resulting message that is shown to the user.
On the Knowledge Base Settings the saved session timeout can be set in minutes or if left blank it will use the deployment server's 'defaultSuspendAge' setting which by default is 60 minutes.
After this elapsed time a session will be removed from the deployment server and the user will be shown the message 'Expired session, click OK to restart' if they try to use a removed saved session.
With viabl.ai version 5.4 onwards, the optional save button macro has been extended to be passed the saveSessionURL as the first parameter, and, it can also return an option true. Returning true results in the engine automatically rendering the final page (or jumping to the final URL). This can be useful in cases where (for example) the finalURL is dynamically updated, or, the saveSessionURL is sent to the user via (for example) and email. An example macro might look like...
let resumeURL = params[0]; // The save session URL is passed as the first parameter
console.log(resumeURL); // Write the URL to the console
return true; // tell the engine to go to the final display or call the finalURL