Conditions

In this tutorial, we’ll show how to set up conditions on your models. We’ll also examine the different types of conditions and how they’re typically used.

Conditions are used to limit the records that are returned via a model (if you’re familiar with SOQL, they’re like the WHERE clause in a SOQL statement). You can use conditions so that only a single record will be displayed (like a detail page) or you can use conditions to filter the records that are shown on a tab/list page or within a table showing related data. The conditions builder enables you to add conditions to the models on your pages.

Conditions: the basics

Add a Condition to a Model.

image0

  1. Click Models. Learn more about using models.
  2. Click on a Model.
  3. Click Conditions and click to Add a new condition.
  4. Click on the new condition to edit it.

Choose the field that you want to use in this condition.

image1

  1. Click Field.
  2. Click on the field-picker icon to choose a field from the model object.

Select an Operator for the condition.

image2

  1. Click Operator.
  2. Choose the appropriate operator from the picklist.

Choose Content, and enter a value.

image3

  1. Click Value.
  2. Choose the Content from the picklist and enter the appropriate value:

Single specified value

image4

A single specified value condition only returns records from your model that have a specific value in the specified field. For example, the condition above will only show Opportunity Records where the Amount is greater than or equal to $50000.

More examples: Only show Opportunities where the Stage is Closed Won, only show Accounts where the Industry is Education, only show Contacts where mailing state is Texas, etc.

Multiple specified values

image5

The multiple specified values condition only returns records from the model that have one of a specific set of values in a specified field. For example, the condition above will only show Opportunity records where the Lead Source is Web or Other.

More examples: Only show Accounts where the mailing state is WA, OR, or CA; only show Contacts where Title is CEO or CFO, etc.

URL Parameter

image6

The URL parameter condition is one of the most commonly used condition types and is most commonly used to pass a record’s id to a page (the “id=xxxxxxxxxxxx” part of a page’s URL). You’ll need to use this type of condition for any Skuid page that you’d like to use as an override for the Salesforce View, Edit, or Clone actions.

The condition above shows Opportunity records where Id is the Id parameter in the page’s url. This condition will cause the model to display only the Opportunity record whose Id equals the value specified by the “id” parameter in the URL.

For example, for an Account detail page that shows related Contacts, Cases, and Opportunities, you would use this condition on each of your models to ensure that you only show 1 Account and only the Contacts, Cases, and Opps that are related to it:

  • Only show the Account record where the Id is the Id parameter in the page’s url
  • Only show Contact records where the Account Id = is the Id parameter in the page’s url
  • Only show Case records where the Account Id = is the Id parameter in the page’s url
  • Only show Opportunity records where the Account Id = is the Id parameter in the page’s url

UserInfo of page viewer

image7

The UserInfo of page viewer condition will only return records from the model if the value of a particular field on the object matches the value of a specified field on the current user’s record. The condition above will only return Opportunity records where OwnerId is the Id of the user running this page and could be used on a “My Opportunity” type page where you want users to see only the Opportunities they own.

More examples: Only show Accounts where Currency is the Default Currency of the user running the page, only show Cases where the LastModifiedBy Id is the Id of the user running this page, etc.

None - blank value

image8

Blank Value lets you choose to return records where the specified field is null. For example, the condition above will only return Opportunity records where LeadSource is a blank value.

More examples: return Leads where Converted Date is null, show Contacts without an Account (where Account Id is blank) etc.

Field from another model

image9

The “Field from another model” condition lets you link models through setting up a relationship between their fields. (You need at least two models on your page to utilize this condition type.) For most pages, you could also accomplish this through a URL parameter (see above) but for clone pages and creating linked records, you must use the “Field from another model” condition to successfully link model data (this is like the Model Merge condition in earlier versions of Skuid).

In this example, the condition will only return Case records where ContactId is the value of the Id field from the first row of the ContactData model, that is only Cases that are related to the first (or only) Contact on your page.

Result of subquery

image10

“Result of subquery” lets you to create conditions in your models that simulate subconditions in SOQL. For example if you wanted to create a model that returned all opportunities from accounts that were in the Education Industry, create this condition on a model for the Opportunity object:

  1. Set the Field to Account Id.
  2. Click Value, and for Content choose Result of Subquery.
  3. Set the Join Object to Account and the Join Field to Id.
  4. Click the button to Add a subcondition.
  5. Make the subcondition a Single Value type, set the Field to Industry and the value to “Education”.

For more detailed information about this Condition type, check out the tutorial on the Result of Subquery Condition.

Condition State

Condition State: Determines whether the condition will be Always On or Always Off (like if you made an awesome condition but want to save it for later). You can also choose to make this condition Filterable and On or Off by default. For more information, see the tutorial Adding Filters to a Table.

Condition Location: Specify whether the condition is applied server-side or client-side.

  • Server: The model on which the condition is applied will query the data source with conditions as parameters and wait for the data source to return filtered results.
  • Client: The condition will be applied to results already returned by the data source, filtering the data in a model without having that model send a new query.

Special Conditions: Grouping

Grouping Logic: Order Conditions

image12

By default, all conditions are applied. The Grouping Logic determines how to group and apply conditions when loading the Model, e.g. ((1 AND 2) OR (3 AND 4)).

Note

This can complicate the application of filters. It’s better to leave this blank, unless you need to fill it out.

  1. Click on Conditions.
  2. Create an overall Grouping Logic for the conditions on the Model.

Special Conditions: Limit Records displayed with the Result of Subquery Condition

The Result of Subquery Condition allows you to create conditions in your models that simulate subconditions in SOQL. For example if you wanted to create a model that returned all contacts from accounts that were in the Education Industry, you want to create a SOQL statement like this:

1
2
3
4
5
6
7
8
9
SELECT Id, Name

FROM Contact

WHERE AccountId IN (

SELECT Id FROM Account WHERE Industry = 'Education'

)

In Skuid, to construct a model like this, you would add a new condition, and select the content type “Result of Subquery.”

Let’s look at how to create an example, a condition that will only display Contacts from Accounts in a specified industry (e.g. Education).

Create a Contact Model

image13

  1. In the App Composer, click Models.
  2. Click Add Model fa-plus-circle.

image14

  1. Enter a Model Id (this can be anything you choose, ideally something to do with the Contact Object).
  2. For SObject Type, start typing the name of a standard or custom object (e.g. Contact), and then select it from the dropdown list.

Click on Conditions and then click New

image15

Click on the Field-picker icon and select Account ID

image16

This is the lookup field to the related object, e.g. Account ID or, for custom relationships, Account__c.

Click Value and select Result of Subquery as the Content type.

image17

Choose Account as the Join Object

image18

Start typing in the Join Object field, and select Account from the list of objects that will appear.

Click on the Join Field-picker icon and also select Account ID

image19

This should be the Salesforce Record Id field.

Click to Add a Subcondition

image20

Create a Single Value condition where Industry is Education

image21

  1. Choose Industry as the field.
  2. Click Value.
  3. Enter Education as the value.

Click Save, then click Preview.

image22

Result: Only Contacts from the Education Industry will be displayed.

image23

The table set to the Contact model now only displays Contacts from Accounts in the Education Industry. Wouldn’t it be cool if you could turn this condition on and off on the page? Actually, you can.

Take the next step: make the Subquery condition a Toggle Filter

image24

Check out this tutorial to make this condition a toggle filter.

Special Conditions: Distance Conditions

For Salesforce location fields (that are linked to latitude and longitude, like Address), Skuid allows you to create distance conditions. In this tutorial, we’re creating a condition that will return records within a specified distance from the person using the page. Read on to learn how!

Click Compose to compose a new Skuid page or navigate to a previously built one

image25

In this example, we’ll be using a Leads Tab page.

Add a Model and click to add a new Condition

image26

What’s a Model, you ask? Here’s Everything You Need to Know about Skuid Models.

Configure your distance condition

image27

  1. Choose a location field, like Address.
  2. For Operator we’ll choose less than for this example.
  3. For units, choose Miles or Kilometers.
  4. For Comparison Location Source (i.e. what to measure this distance from) we’ll choose Running user’s location (but note that you can also measure from a page/URL Parameter, or even a field from another model. Pretty cool, right?)
  5. If user’s location cannot be determined, then Abort this Model’s query.
  6. Make this condition modifiable by filters but off by default.

Create a Distance Filter

image28

  1. Add a table component on this model.
  2. Click Add Features.
  3. Click Add Table Filter.

Create a Manual Select Option filter on your Address condition

image29

Label this filter, add a “None Selected” Option, and click to add a source

image30

Choose Manual as the Source Type and click to add Options

image31

I may have gotten a little Option-happy…

For each option, add a Label and a Value

image32

  1. The Label is what text will get shown to the user.
  2. The Value is what will be injected into the condition,

Click Save, then click Preview to open your page in a new tab.

image33

Let this page know your location.

image34

image35

Success! Now you can filter by distance.

image36

Troubleshooting Distance Conditions

image37

  • One reason your location condition may not be working is that you may not have locations set for your records in Salesforce… Add the latitude and longitude fileds in this table to easily edit them (Address reads from these fields, that’s why our filter on the Address field works).

  • This example didn’t work for me until I chose to” Abort this Model’s Query if user location is not determined” (see Step 2).

    You need to give this page permission to access your location (see Step