---
description: Learn how to handle priorities returned by Keyfax
---

# Handling Priorities

[priorities](../../product-suite/admin/entities/priorities "mention") within Keyfax can be set via a service, task or script level override. When Keyfax completes and results are returned via a call to the Keyfax [rest-api](../apis/rest-api "mention") 2 important properties are returned..

* `Priority` - An alphanumeric priority code as defined within Keyfax Administrator Tools. This value is set via the “Priority Code” field within Keyfax when editing a priority. This priority code would typically correspond to a priority Identifier within your host system.
* `PriorityId` - The internal priority ID for the priority within the Keyfax database. This can often be ignored for integrations and is provided as more of a convenience.

### Keyfax Services (Staff)

[services](../../product-suite/admin/entities/services "mention") returned within Keyfax repair diagnostic results will look like so...

```
{
    "KeyfaxData": {
        "Fault": {         
            "Repair": {
                "@name": "Repair1",
                "CompleteBy": "06/09/2022 10:15:18",
                "ResponseDays": "28",
                "Priority": "R",
                "PriorityId": "2105",
                "RepairCode": "INSP",
                "RepairCodeEx": "INSP",
                "RepairCodeDesc": "Inspection by Technical Officer",
                "UnitOfMeasure": "No",
                "UnitOfMeasureQuantity": "1",
                "Contractor": "T01",
                "IsDeleted": "False",
                "IsDirty": "False",
                "IsNew": "True"
            },           
        },
        "GUID": "e728783b-fe9f-40bf-9f39-5329d77161b7",
        "Status": "1"
    }
}
```

Notice the returned `Priority` and `PriorityId` properties. These are the important values you'll need to obtain to set or determine a priority within your host system. This will often be just the `Priority` property. This `Priority` property should correspond to an identifier for the priority you wish to set within your host system.

### Script Level

Within a Keyfax script if a service has already been added the priority for that service can be overriden as shown below...

<figure><img src="https://2882349412-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MARm6St_qFGM52R3pBa%2Fuploads%2FGLDXdhwstprTXMlVX86s%2Fimage.png?alt=media&#x26;token=58154a23-bfa1-4d4a-84da-f60c1f5cf6bb" alt=""><figcaption></figcaption></figure>

If a PRI action is set after the service is added this priority will override any priority set via the added service. The overridden priority will still be returned within the `RepairCode` property as shown above.

If a PRI action is set before the service is added or a PRI action is NOT set after the service is added within the Keyfax script then the priority associated with the service will be returned within the Keyfax results.

### Export XML

If Keyfax doesn't return services optional top level `Priority` and `PriorityId` properties can be returned within the Keyfax results to still allow script authors to set priorities for paticular scripts. These fields would need to be enabled within your Keyfax results. Please [support](../../links/support "mention") for assistance. &#x20;
