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.
Click the pencil icon of the Navigation field. Set the button action as “Next” and rename the field as shown below.
Page 2-
Drag and drop a Salesforce Lookup field, a JavaScript field and two Navigation fields.
Click the pencil icon of the salesforce Lookup field. Set the object and Display Additional fields as shown below.
Click the pencil icon of the JavaScript field and paste the code. Save the changes.
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.
Click the pencil icon of the first Navigation field. Set the button action as “Next” and rename the field as shown below.
Click the pencil icon of the second Navigation field. Set the button action as “Back” and rename the field as shown below.
Page 3-
Drag and drop a Navigation field for the form submission.
Click the pencil icon of the Navigation field. Set the button action as “Submit” and rename the field as shown below.
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.
Please try out the attached example form:
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂