In this guide, we will share an example of how to save Salesforce Lookup and Salesforce Select field record selections for all future form entries. This will allow users to select the Salesforce record once and save it for all subsequent form submissions.
Please update the field_id
to the Salesforce field you would like set as default.
// Set Salesforce foeld id
var field_id = 'ee5b-c9ab-d2e2';
// Get form template Id
var form_id = window.formyoula.form_entry.get( 'template_id' );
// Check saved value
if ( localStorage[ form_id + field_id + '_id' ] ) {
// Set value
window.formyoula.form_fields[ field_id ].set( {
value: localStorage[ form_id + field_id + '_id' ],
name: localStorage[ form_id + field_id + '_name' ]
} );
}
// Listen to field changes
window.formyoula.form_fields[ field_id ].on( 'all', function() {
// Set in default values
localStorage[ form_id + field_id + '_id' ] = this.get( 'value' );
localStorage[ form_id + field_id + '_name' ] = this.get( 'name' );
} );
Copy the above JavaScript and paste in a new JavaScript field on the form.
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂