---
title: "Example  19 - Before Closure Screen - Prevent closing of Work Order without time registrations"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/6318587905/Example++19+-+Before+Closure+Screen+-+Prevent+closing+of+Work+Order+without+time+registrations"
format: markdown
---
For Details check: [https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5381455880](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5381455880)

This example might not have an immediate practical use, but it can serve as a starting point for creating one.

It prevents a work order to be closed if there are no time registrations attached to it

```json
{
    "Id": "EXAMPLE-19",
    "Name": "Prevent Work Order Closure without time registrations",
    "Code__c": "BEFORECLOSURE",
    "Error_Message__c": "You can not close Work Order without Time Registration!",
    "Formula__c": "",
    "SwiftFormula": {
      "params": [
        {
          "var": "${CURRENT_WORK_ORDER_ID}",
          "constant": "${Constants.CURRENT_WORK_ORDER_ID}"
        }
      ],
      "helpers": [
        {
          "context": "GLOBAL",
          "method": "_.findIndex",
          "from": "FIELDBUDDY__Timesheet_Lineitem__c",
          "where": {
            "fields": [
              "FIELDBUDDY__Work_Order__c"
            ],
            "values": [
              "${CURRENT_WORK_ORDER_ID}"
            ]
          },
          "var": "${RELATED_TIMESHEETS_INDEX}"
        }
      ],
      "formula": "f=()=>{ return ${RELATED_TIMESHEETS_INDEX} === -1; }; Boolean(f());"
    },
    "Mobile_Page__r": ""
}
```



![image-20250731-142435.png](media://3f0844f7-6730-4157-b384-1073e4a6cd0f)