Implementing a Conditional Start Screen

Add conditions that determine which start screen the user sees based on the conditions.

Like the conditional success navigation feature, there is a table of condition names with the matching Start screen. If all of the conditions are evaluated as false (or if they are absent), the default navigation is executed.
  1. In the Flow Design page, select the server-initiated starting point to see the Properties.
  2. In the Properties view, click Start Screen(s).
  3. Click Add to add a condition.
  4. In the dialog, enter the condition name, select the target screen with which to associate the condition, and click OK.
    This means that if the defined condition is found to be true, the screen you choose here will be the start screen. Condition names can include:
    • Letters A-Z and a-z
    • Numbers 0-9
    • Embedded spaces (beginning and ending spaces are trimmed off)
    • Special characters in the set $._-+
    In the Flow Design page, you can see the flow line for the conditional start is a shade of gray to differentiate it from the default GoTo line.

    conditional_start
  5. Add you custom code to the Custom.js file. For example:
    function customConditionalNavigation( currentScreenKey, actionName, 
      defaultNextScreen,  conditionName,
      workflowMessage ) {
        if((currentScreenKey === SERVERINITIATEDFLAG) && (actionName === '')) {
          // conditional start screen uses this magic screen key and the empty action name.
          if( conditionName === 'Wilma_first_ss1') {
              // custom logic
              return true;
          }
          else if(conditionName === 'Fred_second_screen'){
              // custom logic
              // return true or false
              return false;
          }
        }
        // default case is to NOT change the flow
        return false;
    }
    
  6. Regenerate the Mobile Workflow package.
    When you regenerate the Mobile Workflow package, the Workflow.js file is regenerated. The conditional start screen method is shown in the Workflow.js file similar to this:
    function customNavigationEntry() {
        this.condition;
        this.screen;
    }
    function customNavigationEntry( a_condition, a_screen ) {
        this.condition = a_condition;
        this.screen = a_screen;
    }
    
    /**
     * For the specific pair - screen named 'currentScreenKey' and the action 'actionName', return
     * the list of custom navigation condition-names and their destination screens.
     */
    function getCustomNavigations( currentScreenKey, actionName )  {
        var customNavigations = new Array();
        if((currentScreenKey === SERVERINITIATEDFLAG) && (actionName === '')) {                        
    	customNavigations[0] = new customNavigationEntry( 'Wilma_first_ss1',    'Screen_Start_One' );                        
    	customNavigations[1] = new customNavigationEntry( 'Fred_second_screen', 'Screen_Start_Two' );
    return customNavigations;
        }
        return customNavigations;
    }