There are instances where a simple Button or GoToPage isn't an ideal solution for navigating between pages. Possibly you wish to apply complex validation to a page, or complete some specific actions before leaving the page. This could be achieved by having a JavaScript Button that runs some code and then uses
.click() on a hidden Button (
as described here) to take the agent to the desired page, but it's easier to simply use
Script.Utils.Navigate() directly in many cases, and it makes some advanced script-building easier and cleaner.
The usage is straightforward, call the function with the name of your destination script page as the parameter:
Script.Utils.Navigate('Destination Page Name');
Example
Case 1: the script will wait until an External Data Source has returned before automatically progressing without further agent input, while also setting a variable to be displayed on the next page. This case suggests using a Calculate field to call the Script.Utils.Navigate() within a conditional:
if ([External Data Source] == "done") {
if ([Product Quantity] == 0) {
[var_SaleText] = "You've not ordered anything this time.";
}
else if ([Product Quantity] == 1) {
[var_SaleText] = "Your order for one " + [Product Type] + " has been placed successfully.";
}
else {
[var_SaleText] = "Your order for " + [Product Quantity] + " " + [Product Type] + " has been placed successfully, and your multibuy discount applied.";
}
Script.Utils.Navigate('05 Submit Contract Details');
}
Case 2: the agent clicks on a button that decides where to route the agent and what to do based on several conditions. In this case, a JavaScript Button is most appropriate:
if ([Support Request] == "Complete") {
Script.Utils.Navigate('30 Support Updated');
}
else if ([Sales Query Resolved] == "false") {
CS.Dialog.Alert("We'll just need to take a few more details from you before we proceed");
Script.Fields.Show("[Further Sales Details]", "[Sales Channel Checkbox]");
}
else if ([Sales Query Resolved] == "true") {
Script.Utils.Navigate('54 Sales Wrap Up');
}
else {
CS.Dialog.Alert("Please choose a call reason and input required details before trying to continue");
}
Further Notes
It should be noted that this does have a few downsides compared with using a normal button being fired by a .click() event.
Firstly, if the name of the destination page is changed, then the Script.Utils.Navigate() call won't work again until its parameter is updated to the new page name. This contrasts with normal buttons that remain linked to the destination page, even if the page's name is changed.
Secondly, the Check Script functionality doesn't detect the links that Script.Utils.Navigate() create. This means that when manually running Check Script or trying to publish a version of the script, the checker will alert that there are unlinked pages.
Article ID: 3033, Created: January 19, 2017 at 9:44 AM, Modified: February 17, 2017 at 9:27 AM