The User Will Be Able To Go To The Submit Page If The Radio Select Has A Specific Value And The Salesforce Lookup Is Not Empty

In this guide, we will demonstrate the use case where the user will be able to go to the Submit page if the Radio Select value is “Select one” and the Salesforce Lookup is not empty, else the form will show an error message.

In this example, we will create a form with tree pages. Please Disable Standard Navigation on the setup page, we will use custom Navigation buttons.

Page 1:

Drag and drop a Radio Select and a Navigation field.

image

Click the pencil icon of the Navigation field. Set the button action as “Next” and rename the field as shown below.

image

Page 2-

Drag and drop a Salesforce Lookup field, a JavaScript field and two Navigation fields.

image

Click the pencil icon of the salesforce Lookup field. Set the object and Display Additional fields as shown below.

image

Click the pencil icon of the JavaScript field and paste the code. Save the changes.

image

Please use the code below:

// Define ID's of the fields
var custom_navigation_button_id = 'component-afa2-6cc4-a637';
var Radio_select_id = 'Radio Select List';
var Lookup_id = 'Record Lookup';
// On click of custom navigation button
$( '#' + custom_navigation_button_id + ' .btn' ).on( 'click', function( event ) {
  // Get value of radio and lookup field
  var Radio_select = formyoula.form_fields[ Radio_select_id ].get( 'value' );
  var Lookup = formyoula.form_fields[ Lookup_id ].get( 'value' );
  // If condition satisfies
  if ( Radio_select == 'Select One' && Lookup ) {
    // click next button true
    return true;
    // Else
  } else {
    // Alert message
    alert( 'message' );
    // Do not navigate to next page
    return false;
  }
} );

Update the field Id according to your form.

image

Click the pencil icon of the first Navigation field. Set the button action as “Next” and rename the field as shown below.

image

Click the pencil icon of the second Navigation field. Set the button action as “Back” and rename the field as shown below.

image

Page 3-

Drag and drop a Navigation field for the form submission.

image

Click the pencil icon of the Navigation field. Set the button action as “Submit” and rename the field as shown below.

image

Try the form. The user will be able to go to the Submit page if the Radio Select value is “Select one” and the Salesforce Lookup is not empty. Otherwise, it will show an error message.

image
image
image

Please try out the attached example form:

Example Form.json8.1KB

For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂