---
title: "Work Orders in Swift based on Appointments from DispatchPanel"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/5520883713/Work%20Orders%20in%20Swift%20based%20on%20Appointments%20from%20DispatchPanel"
format: markdown
---
## Default Implementation

As of now, reference ([this](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5346689039)) configuration determines returned work orders to Swift as work orders, where Owner is a current user and start/end time of a work order

It is described in a condition similar to one below:

`"Condition": "(OwnerId = :userId ) AND (T_Start_Time__c = LAST_N_DAYS:14 OR T_Start_Time__c = NEXT_N_DAYS:14) AND T_Start_Time__c != null AND T_End_Time__c != null"`  
Briefcase   


![image-20240404-075731.png](media://a0282d39-bf79-44dd-8974-0590951befe0)

That requires work order owner to be properly set when work order is planned for the user.  
Usually it is done by Standard DP Sync module, that will update Owner of a Work Order and start/end times based on planned Appointment in Dispatch Panel.

## Another approach

But in some cases, like having multiple users on the same work order, or due to another reasons, it is necessary to describe which work orders are returned based on Appointments from Dispatch Panel.

It is possible to do it via Briefcase. Due to its flexible structure, it is possible to filter out all the resource assignments where current user is linked to the resource, and then take all the work orders.

It could be done via following structure in a Briefcase

1. Main entity is Resource Assignment. FIlter by the date range and all assigned to an appropriate resource  
`"Condition": "FIELDBUDDY__Resource2__r.FIELDBUDDY__User__c = :userId AND (FIELDBUDDY__Start_Time__c = LAST_N_DAYS:14 OR FIELDBUDDY__Start_Time__c = NEXT_N_DAYS:14)"`
2. Refer fields like start and end time from `FIELDBUDDY__Resource_Assignment__c` as well as Work Order `(FIELDBUDDY__Work_Order__c)`
3. As a `Children` - refer the Work Order object with all child elements as in briefcase.
  1. Ensure to include a `Reference` property - `"Reference": "FIELDBUDDY__Work_Order__c",`
  2. Adjust a filter on Work Order to do not perform filtering on a Work Order
4. in App Settings, in Swift Config, ensure to set `"applyOnlyUserChanges": false`, otherwise all the changes to WO and entities below will be ignored if current user is not owner of a work order

So essentially, wrap the entry for a Work Order with an extra layer of `FIELDBUDDY__Resource_Assignment__c`

This is an sample example:

```json
[
    {
        "Children": [
            {
                "Children": [],//RELATED ENTITIES TO Work Order
                "Fields": [],//FIELDS
                "Condition": "(T_Start_Time__c = LAST_N_DAYS:30 OR T_Start_Time__c = NEXT_N_DAYS:30) AND T_Start_Time__c != null AND T_End_Time__c != null",
                "Reference": "FIELDBUDDY__Work_Order__c",
                "ReferenceCondition": "Id in :idList",
                "RefreshCondition": "LastModifiedDate >= :newDate",
                "ReturnAttachments": true,
                "Target": "FIELDBUDDY__Work_Order__c"
            }
        ],
        "Fields": [
            "Id",
            "FIELDBUDDY__Start_Time__c",
            "FIELDBUDDY__End_Time__c",
            "FIELDBUDDY__Work_Order__c"
        ],
        "RefreshCondition": "LastModifiedDate >= :newDate",
        "Condition": "FIELDBUDDY__Resource2__r.FIELDBUDDY__User__c = :userId AND (FIELDBUDDY__Start_Time__c = LAST_N_DAYS:14 OR FIELDBUDDY__Start_Time__c = NEXT_N_DAYS:14)",
        "Target": "FIELDBUDDY__Resource_Assignment__c"
    }, 
    { ...//remaining briefcase entries
]
```

## Important considerations

1. Work Order is still key object and will be shown in Swift. So `T_Start_Time__c` and `T_End_Time__c` should be set on work order
2. All the Absences, or another Resource Assignment data will not be shown in Swift
3. Limits still apply. Essentially each extra resource assignment will contribute to cumulative limit of records ([https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5267521549](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5267521549) )
4. **Related Work Work Orders do not work in this scenario (expected to work in the future)**
5. It is also planned to develop support for Swift to show Resource Assignments (expected to work in far future)