---
title: "Example 20 - Before Closure Screen - Prevent closing a Work Order when it contains open items."
canonical: "https://help.fieldbuddy.com/space/FBDOCS/6440714241/Example+20+-+Before+Closure+Screen+-+Prevent+closing+a+Work+Order+when+it+contains+open+items."
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. 

Demonstrates how to prevent access to the Closure Screen when all the items remain open.

```
{
    "Id": "EXAMPLE-20",
    "Name": "At least 1 item is Closed",
    "Code__c": "BEFORECLOSURE",
    "Error_Message__c": "At least 1 item is Closed",
    "Formula__c": "",
    "SwiftFormula": {
        "params": [
            {
                "var": "${CURRENT_WORK_ORDER_ID}",
                "constant": "${Constants.CURRENT_WORK_ORDER_ID}"
            }
        ],
        "helpers": [
            {
                "context": "GLOBAL",
                "method": "_.findIndex",
                "from": "FIELDBUDDY__Work_Order_Line_Item__c",
                "where": {
                    "fields": [
                        "FIELDBUDDY__Status__c",                                                
                        "FIELDBUDDY__Work_Order__c"
                    ],
                    "values": [
                        "Closed",
                        "${CURRENT_WORK_ORDER_ID}"
                    ]
                },
                "var": "${COUNT_OF_CLOSED_WOLIS}"
            }
        ],
        "formula": "f=()=>{return ${COUNT_OF_CLOSED_WOLIS} < 0;};Boolean(f());"
    },
    "Mobile_Page__r": ""
}
```