---
title: "Example 10 - Before Closure Screen - Ensure all Activities are closed"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/5987860483/Example+10+-+Before+Closure+Screen+-+Ensure+all+Activities+are+closed"
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 shows how to prevent accessing the Closure Screen if any activity is still open (when its status is 'Open').

```
{
    "Id": "EXAMPLE-10",
    "Name": "Disable WO Closure without non-completed activities",
    "Code__c": "BEFORECLOSURE",
    "Error_Message__c": "Close all the activities!",
    "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__Type__c",
                        "FIELDBUDDY__Work_Order__c"
                    ],
                    "values": [
                        [
                            "Open",
                            ""
                        ],
                        "Activity",
                        "${CURRENT_WORK_ORDER_ID}"
                    ]
                },
                "var": "${ACTIVITY_OPEN_INDEX}"
            }
        ],
        "formula": "f=()=>{return  ${ACTIVITY_OPEN_INDEX} >= 0;};Boolean(f());"
    },
    "Mobile_Page__r": ""
}
```


![Example-10-Before Closure Screen-2.png](media://d06057ae-584a-462f-b433-13f2f4a67838)



![Example-10-Before Closure Screen-1.png](media://68f86d9b-c77e-4ecc-836a-199b6c6bdfa1)


```
EXAMPLE-10 Disable WO Closure without non-completed activities at 
f=()=>{return 28 >= 0 || 28 >= 0;};Boolean(f());
Pass: false
ErrorMessage: Close all the activities!
```