Offline Salesforce Record Filter Using Merge Fields

In this guide, we will show how to filter Salesforce fields based on Parent records using merge fields.

  1. Please add a Salesforce Lookup field. In this example, we will use the Account Object:
image
  1. Please add a Salesforce Select field. We will use the Contact Object:
image
  1. Please add the below record filter. This will make sure to return only the Contact records that are related to the selected Account record.
AccountId = '{{cca6-9b0e-0094}}’ 
image

{{cca6-9b0e-0094}} = Account Lookup merge field ID. The merge field IDs can be located on the bottom of each field:

image
  1. Please add the below offline record filter under the Advanced settings on the Contact Salesforce Select:
(function(result) {
    var AccountId = formyoula.form_fields["cca6-9b0e-0094"].get('value');
    return result.AccountId == AccountId;
});
image
  1. Please select the necessary fields to display once the Contact records are returned on the form. Please make sure to select the Parent field, in this case, we are selecting the “Account ID” field as we are filtering the Contact records based on the Account Lookup field:
image

Filtering based on multiple Parent fields:

  1. Please add another Salesforce Select. We will use the Case Object:
image
  1. Please add the below record filter. We will filter the Case records based on the Account and Contact Parent fields:
AccountId = '{{cca6-9b0e-0094}}' AND ContactId = '{{6e38-d519-6970}}'
image
  1. Please add the below offline record filter under the Advanced settings on the Case Salesforce Select:
(function(result) {
    var AccountId = formyoula.form_fields["cca6-9b0e-0094"].get('value');
    var ContactId = formyoula.form_fields["6e38-d519-6970"].get('value');
    return (result.AccountId == AccountId && result.ContactId == ContactId);
});
image
  1. Please select the necessary fields to display once the Case records are returned on the form. Please make sure to select the Parent fields, in this case, we are selecting the “Account ID” and “Contact ID fields as we are filtering the Case records based on the Account and Contact fields:
image

Now once using the form in offline mode, we will be able to select the Contact and Case records filtered based on their Parent records:

Contact records filtered based on the Account Parent field:

image

Case records filtered based on the Account and Contact Parent fields:

image

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