---
title: "JS Formula Helpers"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/5382144004/JS%20Formula%20Helpers"
format: markdown
---
Helpers allows to access the various records in database, based on scope of current record.

Below are the helpers that could be used in validation rules:

### _.first

Allows you to find a record in local storage of FieldBuddy Swift. Might be handy if you want to check field on parent record of WO while saving a WOLI with a help of special reference `CURRENT_WORK_ORDER_ID`.

```
{
    "context": "GLOBAL",
    "method": "_.first",
    "select": "FIELDBUDDY__Type__c",
    "from": "FIELDBUDDY__Work_Order__c",
    "where": {
        "fields": [
            "Id"
        ],
        "values": [
            "${CURRENT_WORK_ORDER_ID}"
        ]
    },
    "var": "${WO_TYPE}"
}
```


### _.findIndex

Allows you to find an index (in the world of JS - [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) , practical sense – if found > -1, otherwise -1) of a record of certain criteria.

Support search based on values of fields in a format of parallel arrays (fields/values) properties. Returns variable that holds the index.

```
{
    "context": "GLOBAL",
    "method": "_.findIndex",
    "from": "FIELDBUDDY__Work_Order_Line_Item__c",
    "where": {
        "fields": [
            "FIELDBUDDY__Status__c",
            "FIELDBUDDY__Type__c",
            "Name",
            "FIELDBUDDY__Work_Order__c"
        ],
        "values": [
            [
                "Open",
                ""
            ],
            "Activity",
            "%Checklist",
            "${CURRENT_WORK_ORDER_ID}"
        ]
    },
    "var": "${CHECKLIST_OPEN_INDEX}"
},
```

### _.count

Allows you to find the count of records in local storage of FieldBuddy Swift.

For example, this can count a amount of TSLI of certain type under WOs

```
  {
      "method": "_.count",
      "select": "Id",
      "from": "FIELDBUDDY__Timesheet_Lineitem__c",
      "where": {
          "fields": [
              "FIELDBUDDY__Type__c",
              "FIELDBUDDY__Work_Order__c"
          ],
          "values": [
              "Servicebezoek",
              "${ID}"
          ]
      },
      "var": "${SERVICEBEZOEK_COUNT}"
  }
```


### _.filter

Allows you to find multiple records in local storage of FieldBuddy Swift, and use them in validation rules

See this example for how it can be utilised: [https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/6277201921](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/6277201921)