Chaining Multiple Actions Together

When creating a workflow that requires multiple processes to occur on a single page, it is often important that each step of the process happens in the correct order. It is also likely that some steps in the process would rely on earlier steps being completed successfully in order to work as expected, or that the result of an earlier step will decide on the steps that follow.
Below are examples that use functionality built into Synergy and/or logic within JavaScript code to achieve a chained process involving multiple steps, which will help to prevent race conditions from occurring within your workflow.

Update Links

Update Links are a feature available when using a Table or External Data Source control. When the current action has been completed, Update Links can be used to do one or more of the following actions:
  • Click a Button control,
  • Click a JavaScript - Button control,
  • Reload a Table control (will cause the Table to re-execute its query),
  • Trigger an External Data Source control (will cause the EDS to execute its query),
  • Trigger any other control mentioned in this article.
For example, a custom SQL table has been created to store FAQ / Knowledge Base information and the Workflow needs to be able to display this data to the user whilst also recording how often each FAQ is being used for Management Information (MI) purposes. A set of Table controls are used to filter the FAQ search results, to show the Category, Sub Category and Question, and then display the Question and Answer selected below.
Each Table is linked to the other from left to right so initially when the page loads only the Category Table has relevant data in it, as seen below. The user would then interact with each Table control from left to right, with the links between the controls causing the data to update in the Table to its right:
The following process flow describes the relationships between all of the controls in this example:

JavaScript Logic

JavaScript logic can also be used to control the order in which steps of a process occur, which can be useful when the process needs to change depending on the result of a step. It is possible to use a JavaScript - Button to trigger an External Data Source control, or use a Calculate control to check the result of a SQL query then carry out the subsequent action based upon that result.
For this example, after details are captured then either a new customer record is created or if the customer already exists go to a different page of the Workflow. Should a new customer record be created, the Workflow then only proceeds to the next page when the SQL query has finished and returned a custom result. This is helpful due to a SQL query being asynchronous, so you need to wait for this to have completed before proceeding.
The following controls are present in this example, including some details about the configuration for each control:
  • Text Boxes (used to capture information),
  • JavaScript - Button,
  • Button (this control is hidden, as the script logic will be clicking this button rather than the user),
  • External Data Source (this control is hidden, and not set to run automatically),
  • Calculate,
  • Hidden.
1. Check user inputs & launch process
A JavaScript - Button is used to carry out custom validation of the Workflow using JavaScript code, and give custom messages to the user should this validation fail. Once the validation has been passed, the External Data Source control is clicked using the Synergy Script.Utils.GetCSObject() JavaScript function:
if ([Customer Name] == '') {
        CS.Dialog.Alert('Customer Name must be entered');
else if ([Telephone Number].length < 11) {
        CS.Dialog.Alert('The entered Telephone Number is too short');
else if ([Telephone Number].length > 11) {
        CS.Dialog.Alert('The entered Telephone Number is too long');
else {
        Script.Utils.GetCSObject([Insert Customer Details]).click();
2. SQL query to custom database
The External Data Source control is then configured to check whether the customer already exists in the database, and returns a different result depending on the data. This result is mapped to a Hidden field, and when the Hidden field has data mapped to it this causes all code within the page to be re-evaluated:
        SELECT *
        FROM Customers
        WHERE CustomerName = [Customer Name]
        INSERT INTO Customers (CustomerName, TelephoneNumber)
        VALUES ([Customer Name], [Telephone Number])
        SELECT 'Customer Created' AS 'SQL Result'
        SELECT 'ERROR - Existing Customer' AS 'SQL Result'
3. JavaScript code to check SQL Result
The Calculate field is then used to monitor the value of the [SQL Result] Hidden field, and carries out the required action based on the results that are configured with the External Data Source:
if ([SQL Result] == 'Customer Created') {
else if ([SQL Result] == 'ERROR - Existing Customer') {
        Script.Utils.GetCSObject([Existing Customer - Button]).click();