Enable Salesforce Offline Record Auto Sync Using Form Configuration

In this guide, we will enable Salesforce record offline sync automation using the form template JavaScript field. This will ensure that auto sync is only enabled for the users of this form.

Please drag and drop a JavaScript field on your form and add the following code.

// Set Salesforce Record Auto Sync Type (days, hours, minutes)
localStorage.formyoula_auto_sync_duration_type = 'hours';
// Set Salesforce Record Auto Sync Frequency (Number)
localStorage.formyoula_salesforce_record_auto_sync_frequency = 12;
image

We can also trigger offline sync when the form is open.

// Check if device is online
if ( window.formyoula.is_online() ) {
	// Set current form ID for offline sync
	window.formyoula.salesforce_offline_sync_form_ids = window.formyoula.form_entry.get( 'template_id' );
	// Trigger offline record sync
	window.formyoula.event_trigger( 'setup:offline:search:on', { auto_sync: true } );
}

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