Lookup Fields

Lookup fields (also known as reference fields) define the relationships between objects. Skuid allows you to customize the options available in a lookup field, and how these options are displayed.

This gives an overview of lookup fields:

Lookup Fields at Runtime

LookupsandLookupFilters-0

  1. Start typing to view available records from the related object.
  2. Click on an option from the list to select it.

You can also click on the magnifying glass to view all options.

LookupsandLookupFilters-1

You can also select a record from a lookup by …

  1. Clicking on the magnifying glass, which will open a popup of available records which you can browse and search.
  2. Click on the link next to the desired record.

Click on a Reference Field in the composer area to set up Search and Filter properties.

LookupsandLookupFilters-2

For example, we have a table of Opportunity Contact Roles record and we want to customize the Contact Id lookup field.

Search Properties determine the source of these options and how they are displayed.

LookupsandLookupFilters-3

In the lookup field’s Search tab, you can:

  1. Choose the Option Source:
    • Automatic will include all records from the related object (which you can narrow down using the Filters tab.)
    • Model will include all records from a related object model that you have defined in this page, which allows you to create all sorts of conditions etc. Create a model on the related object (in this case Contact) and it will show up as a choice for the Option Model.
  1. In Display and Search Template you can change how options appear in the list (the default template is the Name field).
    • Make sure the fields you use are included in your model. This is the main model (e.g. Contact Role) if you set Automatic as the option source, or the model on the related object (e.g. Contact) if you set Model as the option source.
    • Use {{curly brackets}} to include the fields you want to show up. In the case of the pound sign, {{#field}}{{field}}{{/field}}, whatever is within the # / tags will only show if the field is ‘truthy’ (i.e. the field has data, or is a checkbox field equal to ‘true’). So, in the examples above, Title will only appear if Contact has a Title.
    • The Display Template will be shown when the field is in read mode, and/or an option has been selected.
    • The Search Template will be shown in the typeahead list when a user is selecting a related object record.
  2. You can also choose to tokenize the search, which searches for instances of all of the multiple search terms, in any order. A tokenized search for “George Washington” returns records with “George Washington,” George Michael Washington,” and “Washington George.” An untokenized search only returns records that contain the exact string entered (“George Washington”) in the search box.

Make sure these fields are included in the appropriate model.

LookupsandLookupFilters-4

This is the model you are using for the option source, or, if you’re using automatic as the action source it’s the model that contains the lookup field — click on the arrow next to the lookup field (e.g. ContactId) to go into the related object and select the fields you’ve included in your templates.

Configure Search fields.

LookupsandLookupFilters-5

Skuid also allows you to chose which fields you search on. By default, the lookup field will perform a SOQL search on all fields in the related object, but you can click on the plus sign to optimize the search by specifying the fields you want to search on and return.

Specify which fields you want to search on, and which ones you want to return in the search popup.

LookupsandLookupFilters-6

Be sure to specify *all* the fields you want to search on and/or use in the the display template and/or the search popup. There may be fields you want to search on, but not show to users, and there may be fields you don’t want to search on but display to the users for more clarification.

  1. Choose a field to include in the search.
  2. Click if you want to Search this Field, and you will have the option to choose the search operator (equals, contains, or starts with).
  3. Choose whether or not to Return field in query results (i.e. make it visible to the user and/or useable on the page).
  4. Choose whether or not to Show Field in Search Popup. If you choose to show the field, you can add a custom label if you want.

Or, you can use SOSL instead.

LookupsandLookupFilters-7

If you click Use SOSL, you will not be able to add fields via the plus sign, but will be able to choose one of these options:

  • Name Fields
  • All Text Fields
  • Email Fields
  • Phone Fields
  • Sidebar Fields (Name, Phone, Email, External Ids)

SOSL is a great option if you want to search long text fields like “Description”, because SOQL doesn’t do that. For more details about SOQL vs SOSL, see the Skuid on Salesforce expandable text under the Filters and Search tab in the Table topic.

Add Filters to limit the available options.

LookupsandLookupFilters-8

Filters you create will apply to the options available in the lookup. If you’re using a model as the option source, then they will operate in addition to any conditions you have set on that model.

  1. Click Filters.
  2. Click to add a new Lookup Filter.

Click on a filter to configure it.

LookupsandLookupFilters-9

  1. Click on the new filter.
  2. Click on the icon to select a field from the related object.
  3. Set the desired Operator
  4. Choose the appropriate Content (your options should look familiar because they are the same as the ones availalbe model conditions, with one addition).
    • Single Specified Value
    • Multiple Specified Value
    • Page/URL parameter Value
    • Running user attribute
    • None - blank value
    • Field from another model
    • Another field from row (this is the new one, see below)

Remember, for these filters to work, these fields must be included in your model.

Use “Another field from row” as the source to create dependent picklists.

LookupsandLookupFilters-10

If you choose Another field from row as the Content, you can filter the list of related records that appear based on the value of another field on this record. In this example on an Opportunity Contact Role table, the Contact lookup field will only return Contacts from the Account to which the Opportunity belongs. In other words, the Opportunity selected on each record will determine which Contacts are available.

Remember, for these filters to work, this field must be included in your model.