> For the complete documentation index, see [llms.txt](https://docs.keyfax.biz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keyfax.biz/product-suite/admin/databox-examples/higher-priority-jobs.md).

# Higher priority jobs

### Using the priority export databox

How to use the priority export databox to read the service priority and display a message,

{% embed url="<https://youtu.be/IIHsrVQZFzY>" %}

The following example demonstrates how a **Startup script** uses a SQL Databox to check for previous jobs raised within the past 5 minutes by the same user, on the same property and writes the details into a script Databox.

Later, a **Custom Script** checks the details of any previous job found.

### The Startup Script

This is the Startup Script which executes Databox Read i.e. **Keyfax.MultiOrderCheck** where the results are written to the Databox **MultipleJobs.Details:**&#x20;

<div align="center"><figure><img src="/files/3QZ77y4pbmBbbfoPF5Un" alt=""><figcaption><p>The Startup Script</p></figcaption></figure></div>

### The SQL Databox

This query will looks for any orders submitted in the last 5 minutes, for the same operator and Asset ID. The query runs against the Keyfax table **syOrder**:&#x20;

<div align="center"><figure><img src="/files/m3wm3hMvi5xbYoc6FS0y" alt=""><figcaption><p>MultiOrderCheck SQL Databox</p></figcaption></figure></div>

In the WHERE clause, you'll see references to other Databoxes in **{**&#x63;url&#x79;**}** braces, including **Keyfax.DateChecks** below (subtracting 5 minutes from the current time could easily have been done using SQL in the above query but it is split out into a Databox just for demonstration purposes):

<div align="center"><figure><img src="/files/3CpQL9RWPsEcj9yD2l9L" alt=""><figcaption><p>A Databox that subtracts 5 minutes from the current time</p></figcaption></figure></div>

### Using the results of the above Query

The Databox **MultipleJobs.Details** contains a number of Expressions, two of which are Conditional and are checking for values representing the Priority (you will see their use in the **Result script** below).&#x20;

<div align="center"><figure><img src="/files/uQWljkZhDWdW8faj2hz5" alt=""><figcaption><p>MultipleJobs.Details' Expressions</p></figcaption></figure></div>

### The Custom Script

If a job is found and it has an **Urgent** priority then the priority of the current job is checked. If the current job is an **Urgent** or **Emergency** priority then nothing is done. If the current job is a **Routine**, the priority needs to increase to an **Urgent** to match the previous job.

If there is a job found and it has an **Emergency** priority then the priority of the current job is checked. If the current job is an **Emergency** then nothing is done. If the current job is anything else, the priority needs to increase to an **Emergency** to match the previous job.

To add another level of checking, as notification to the Operator, a question is displayed informing the Operator that a priority change is required. If they continue, the priority will be upgraded accordingly.

<div align="left"><figure><img src="/files/FX40uPRVaQKtKha5QCSG" alt=""><figcaption><p>The Priority checking custom script</p></figcaption></figure></div>
