FREE TRAINING: Join us for Open Office Hours every Tuesday at 3 pm ET or for our weekly training webinars. View Schedule >>

Add a reference field to a Form that allows an end user to select from a filtered set of records you define as an administrator

created

Most objects in Salesforce will have a reference field that associates their records with another object. In the simplest example, think Contact object with its Account Id reference field that associates a given Contact with an Organization/Household.

For the Forms app, you can choose to populate reference fields in one of three ways:

  • Hard-coding the value as the Default Value in a hidden form field;
  • Using a value associated with the logged in user, if you have User Integration enabled for your site; or
  • Defining a searchable lookup filter that displays options to the front-end user in a modal popup after they click a Select button next to the field on the form.

To define a searchable lookup filter that allows the front-end user to select an option for a reference field in a Form:

  1. Open the Forms page to which you wish to add the field
  2. Click the Form tab
  3. Click the Add Salesforce Element button
  4. In the Salesforce Field drop down, select the reference field you wish to add
  5. For Searchable Lookup, choose Yes

    screenshot-reference-field-filter.png
  6. For Searchable Lookup Object, type the API name of the object in Salesforce from which you wish to display records to populate the reference field
  7. For Searchable Lookup Display Field, after entering the object in the field above, select the field from that object whose value you wish to display to the front-end user in the popup
  8. For Searchable Lookup Reference Field, after entering the object in the field above, select the field from that object whose value you wish to save to the reference field. In many circumstances, this will be the Id field of the object.
  9. For Searchable Lookup Filters, select the field on which you wish to filter the options displayed to the end user, the operator to be used in that filter (equals or not equals), and the value by which you are filtering. The value can be either a literal character string (e.g., "Active") or a variable associated with a logged in user (e.g., "{$ContactId}"). For more on variables associated with the logged in user that can be used to filter data, see Variables for logged in user available for a Directories page Default Value.
  10. Click Save

Example Use Cases

The simplest scenario for the searchable lookup option is when you wish to show a filtered list of records from the same object that the Form's reference field is associated with. For example, you might have a Form that creates a Contact and you want the end-user to be able to populate the Account Id field of the Contact by selecting an option from a list of all Account records with a Status field of "Active".

A more complex scenario involves showing a filtered list of records from a different object than the one the reference field is associated with. Let's say you have a Form that creates records in the Opportunity object. You have logged in users and the Contacts associated with those logged in users have Organizational Affiliations. You want the logged in user submitting the form to be able to select an Account with which to associate the new Opportunity record by choosing from the Accounts for which the have Organization Affiliation records.

The screenshot above shows an example of this more complex scenario in a Salesforce instance that has its own custom Organization Affiliations object. To execute the same scenario with the Nonprofit Success Pack's Affiliations object, you would want to create a custom formula text field that contain the name of the organization in the affiliation record and could replace the values above with these:

  • Searchable Lookup Object: npe5__Affiliation__c
  • Searchable Lookup Display Field: (select the custom formula text field you created)
  • Searchable Lookup Reference Field: Organization
  • Searchable Lookup Filters: Contact equals {$ContactId}
Have more questions? Submit a request
Article is closed for comments.