---
title: "Filter Logic in Checklists"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/6020071431/Filter+Logic+in+Checklists"
format: markdown
---
> ℹ️ Features described in this page are available from Swift version 3.500.2.


![ScreenRecording_01-24-2025 17-09-51_1.mov](media://cdb30749-e2e6-4f17-b995-d1921738d22e)


![ScreenRecording_01-24-2025 17-11-32_1.mov](media://567d825a-4d40-4d0c-8aef-4bfaf1fddfec)


Checklist fields use filter logic data to allow implementation of conditional rendering behavior in checklists.


With this technology, the fields and pages can be configured to conditionally appear and disappear based on the values users provide for other fields.


You may use this feature to hide irrelevant parts of checklists from users, so that they are not overwhelmed by high amount of fields that are not applicable to them in a checklist.


This document aims to introduce this technology to admins, so that they can correctly implement this behavior in checklists.

This document uses some terminology that is necessary to understand and implement this feature.


# Work Order (Line) Item (WOI/WOLI)

WOIs allow the creation and management of checklists. Every checklist is an instance of a WOI.

## Requirements

- Type must be `Activity`, if you use display type `Checklist`,
- OR any type with the display type `Details` (in this case, `useDetailsAsChecklist` must be turned on via [configuration](https://help.fieldbuddy.com/space/FBDOCS/5670535260/items))


![Simulator Screenshot - iPhone 13 mini - 2025-01-24 at 16.45.52.png](media://7951e20b-4c45-4be4-9d15-2edc06779946)

---

# Work Order (Line) Item Detail (WOID/WOLID)

WOIDs allow the creation and management of the fields you see in checklists. Every checklist field and page are instances of WOIDs.

## Requirements

- If a WOID is meant to be conditionally shown, it must have an implementation of filter logic and API Name (explained in next sections).



![Simulator Screenshot - iPhone 13 mini - 2025-01-24 at 16.47.53.png](media://27e829ce-2d16-4f25-af67-9eee83a949a2)

![Screenshot 2025-01-24 at 16.55.21.png](media://dc9bdd64-34e6-4a78-ab47-97408789314e)

---

# API Name

API Name is basically a unique identifier inside a checklist that refer to that WOID.

Every WOID has an option to have an API Name, which allows Filter Logic to be able to refer to these WOIDs.

> 📝 WOIDs with API Name defined are called **providers**.

## Requirements

- API Names have to be valid JS variable identifiers. You can check if an API Name value is valid here: [https://mothereff.in/js-variables](https://mothereff.in/js-variables)
  - Valid: `myVariable`, `ABC123`,  `__var__`
  - Not valid: `123`, `123ABC`, `function`
- API Names have to be unique within a WOI. In other words, an API Name cannot be shared by two or more WOIDs.

![Screenshot 2025-01-24 at 16.56.59.png](media://8a70d0ec-4eb1-48aa-977b-906254d94194)



---

# Filter Logic

Filter Logic is a JS expression in the form of an [arrow/lambda function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions).

Every WOID has an option to implement a Filter Logic expression, which when evaluated, returns a boolean value (true/false).

> 📝 WOIDs with Filter Logic defined are called **subscribers**.

## Requirements

- Filter logic must conform to the [arrow/lambda function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) interface:
  - `(param1, paramN)=>expression`

> ⚠️ No spaces before or after `=>`

- Every parameter used in the parameter list must be included as a value in the API Name field of a WOID in a WOI.
- If a variable name is in the expression, the variable name has to be included in the parameter list as well.
  - Valid: `(test)=>{return Boolean(test)}`
  - Not valid: `(test1, test2)=>{return  Boolean(test1) && Boolean(test3)}`
    - Because `test3` is not in the parameter list.
- If you have to the character `”`, you must either escape it, or you must use `'` instead. Otherwise expression may not be parsable.
- Make sure to add an API name value to fields to every field with filter logic, as well. Otherwise, the conditionality may not work as expected.




![Screenshot 2025-01-24 at 17.02.13.png](media://ba481420-d87f-48a2-a500-66a72ce21f92)


WOI in the this picture is valid, because:

- It’s a valid JS arrow expression,
- `userOwnsCar`, which is used in the expression, is included in the parameters list.
- `userOwnsCar` is a value of an API Name of another WOID in the same WOI.

---

# How to make a `field` or `page` conditional on other fields' values in three steps

1. Create the WOI and WOIDs.
2. Give API Name values to **provider and subscriber** fields.
  1. Make sure the API Name requirements are fulfilled. See the table above for the requirements.
3. Constuct the filter logic, and assign these to **subscriber** fields.
  1. Make sure the Filter Logic requirements are fulfilled. See the table above for the requirements.

---

## “[Gotcha](https://en.wikipedia.org/wiki/Gotcha_(programming)#:~:text=In%20programming%2C%20a%20gotcha%20is,or%20unreasonable%20in%20its%20outcome.)”: Fields/Pages that are both “providers” and “subscribers”

A field/page can be both a **provider** AND a **subscriber** (have both API Name field AND filter logic field defined).

For example, let’s consider a checklist setup where we want to show the next field only if the previous field is a specific value: “X”.

| **Field** | **API Name** | **Filter Logic** |
| --- | --- | --- |
| Field A | A | - |
| Field B | B | (A)=>{ return A == 'X' } |
| Field C | C | (B)=>{ return B == 'X' } |

The row with the field marked with blue is considered both a provider and a subscriber, since it defines both API Name and Filter Logic.

The cell marked with red shows an incorrectly constructed filter logic.

It should be like this instead:

| **Field** | **API Name** | **Filter Logic** |
| --- | --- | --- |
| Field A | A | - |
| Field B | B | (A)=>{ return A == “X“ } |
| Field C | C | (A, B)=>{ return A == 'X' && B == 'X' } |

> 📝 You should always make sure that any subscriber fields that depend on other subsciber fields also include conditions of the filter logic of those subscriber fields.

---

# Frequently Asked Questions

## Is there a limit to how many fields can depend on each other?

No, there is no such limit.


---

## When should I use a conditional page instead of a conditional field?

You may have a lot of fields that you may want to make conditional. In these cases, it’s smarter to use conditional pages, because you don’t have to individually configure filter logic for each field, but for the page in the general.

For conditional pages, you may also configure a message to be shown when the user presses on a page where the conditions are not (yet) fulfilled. 

This is done with the `Help Text` property in WOIDs, and is optional. Simply type your message there, and if the conditional page’s conditions are not fulfilled, the user will be shown the message. 

If `Help Text` is empty, user will see this generic message instead: `You can’t access this page due to validation.`

---

## How do I do operations on special fields (e.g., numbers, dates)?

All values that will be identified and parsed with API Names are `string` typed. This means that you have to pay attention to make sure of proper type conversion before using numerical or date-specific operations or methods. Example for operations on numbers:

- Incorrect: `(numberA, numberB)=>{if (numberA * numberB > 42) {return true} else {return false}}`
  - numberA and numberB are `strings`. `*` operation does not work with strings; it works with numbers.
- Correct: `(numberA, numberB)=>{if (parseInt(numberA) * parseInt(numberB) > 42) {return true} else {return false}}`

Example for dates:

- Incorrect: `(dateA, dateB)=>{if (dateA.getFullYear() - dateB.getFullYear() === 0) {return true} else {return false}}`
  - dateA and dateB are `strings`. `getFullYear()` method does not work with strings; it works with dates.
- Correct: `(dateA, dateB)=>{if ((new Date(dateA)).getFullYear() - (new Date(dateB)).getFullYear() === 0) {return true} else {return false}}`

---

## Can Picture fields be used as conditional fields?

Yes, you can also use Picture fields as conditional fields. When a picture is attached to a picture field, it’s value is `true`. You can simply use `Boolean(apiName)` to check if a picture field identified by `apiName` has a picture attached (in which `Boolean(apiName)` will return `true` ) or not (in which `Boolean(apiName)` will return `false`).

---

## Can [Formulas](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/3525115909) be combined with Filter Logic?

Yes, both formulas and filter logic can be implemented in the same checklist without problem.

---

## Can a conditional field also be marked as required?

Yes, but doing this is not recommended. When a field is marked as required, it’s completion contributes to checklist progress. If the same field is conditionally hidden, the user might not see the field before the checklist is complete. This means that there would be a possibility to complete a checklist without seeing all the required fields.

---

## Why does the values of fields not clear when they become invisible?

We decided to not clear values of fields when they become invisible, because we did not want to cause trouble to the user in case they make a change that they could not have predicted to affect another field. 

# Implementation Examples

[https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/6023643166](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/6023643166)