> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/projects/use-cases/boards-and-pipelines/field-service-dispatch-queue-lwc.md).

# Build a Salesforce Field Service Dispatch Queue with Avonni LWC

Assign unstaffed field jobs from a queue and see them on a technician schedule. Requires Avonni LWC Components and a field-job object with scheduled times and a technician field.

<figure><img src="https://3857391697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdHOej9Pd5IxJNGEJMZKW%2Fuploads%2FLSaVOArBh6d4mZePoNtT%2Fdispatch-queue-cover.jpg?alt=media" alt="Field Service Dispatch Queue in Salesforce Lightning, with unassigned jobs in Avonni Data Table and scheduled jobs in Avonni Scheduler."><figcaption></figcaption></figure>

### Build the project

Choose how you want to build:

✨ **Build with AI** — Give your AI assistant a ready-to-use prompt.

🛠️ **Build it** — Follow the steps yourself.

{% tabs %}
{% tab title="Build with AI" icon="wand-magic-sparkles" %}
{% stepper %}
{% step %}

#### Set up the assistant and sandbox

Follow [Build with AI](https://docs.avonnicomponents.com/build-with-ai) and use the `avonni-lwc-components` skill. Work in a Salesforce sandbox with Avonni LWC Components installed. Use the same four sample jobs as the manual build.
{% endstep %}

{% step %}

#### Copy the prompt

{% code title="Dispatch Queue build prompt" collapsedlinecount="10" %}

```

Build a Lightning app page workspace using Avonni Data Table and Scheduler inside one LWC. Verify query, mappings, selectrows and refresh against the Avonni MCP. Inspect the sandbox for Field_Job__c or an equivalent object, plus the job name, start, end and writable technician field. Show the field mapping and target sandbox before generating files.



Use the Data Table to list jobs with no technician and allow one row to be selected. Use Scheduler to show assigned jobs on a day timeline, grouped by technician. Add an explicit Assign selected job button. Save with Salesforce UI API and let Salesforce enforce permissions and validation. After a successful save, refresh both Avonni views. After a refused save, show the error and keep the job in the queue. Use one query scope and the same sample date for both views.



Test a successful assignment, a rejected assignment, and clear feedback in the sandbox. Verify the stored technician value and both UI views. Stop before deployment to production.

```

{% endcode %}
{% endstep %}

{% step %}

#### Review and test the workspace

Verify that the queries share the same job scope and that only one record is passed to Salesforce per click. Deploy to the sandbox and run [Try it](#try-it).
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Build it" icon="screwdriver-wrench" %}
{% stepper %}
{% step %}

#### Prepare the sandbox

Install [Avonni LWC Components](https://docs.avonnicomponents.com/lwc-components/getting-started/installation-and-licenses-management). Use `Field_Job__c` with a text `Name`, Date/Time fields `Start__c` and `End__c`, and a nullable text field `Technician__c`. The dispatcher needs read access to the records and edit access to the technician field.

[Download the Salesforce DX starter](https://3857391697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdHOej9Pd5IxJNGEJMZKW%2Fuploads%2F0Zn6S3GUJdoq3Hdk9Rk7%2Fdispatch-queue-lwc-starter.zip?alt=media). Create or map the object and fields before deploying the starter. The included validation rule applies to the sample electrical inspection and rejects Maya Chen for that job.

{% code collapsedlinecount="10" %}

```sh

sf project deploy start --source-dir force-app --target-org <sandbox-alias> --wait 5

sf apex run --file data/seed.apex --target-org <sandbox-alias>

```

{% endcode %}
{% endstep %}

{% step %}

#### Configure the queue and the schedule

Use the Data Table with `Technician__c = null` and one selectable row. Show the job name and scheduled date. Use Scheduler in day timeline mode with `Technician__c != null`. Map Name to the title, Technician to the resource, Start to the start date, and End to the end date.

The starter scopes both queries to the four jobs whose names begin with `Dispatch Queue Demo`. The schedule opens on November 16, 2026.
{% endstep %}

{% step %}

#### Connect selection to the save

Read the selected record ID from the Data Table’s `selectrows` event. Let the dispatcher choose a technician and confirm with **Assign selected job**. The wrapper LWC calls Salesforce `updateRecord`, then refreshes both views after Salesforce accepts the update. Use the returned error to explain a refusal.

Add **Field Service Dispatch Queue** to a Lightning app page, or open `/lightning/cmp/c__avonniDispatchQueue` on the sandbox’s Lightning domain for a direct test.
{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

### Try it

1. Check that **Pump inspection** and **Electrical inspection** are in the queue and that the Scheduler shows Maya Chen and Tomas Berg.
2. Assign **Pump inspection** to Maya Chen. Check that it leaves the queue and appears on Maya’s row without reloading Lightning.
3. Try assigning **Electrical inspection** to Maya Chen. Check that Salesforce shows the certification error, the job stays in the queue, and the Scheduler shows no new job for it.

**Sandbox result.** In Salesforce Lightning, a sandbox admin assigned Pump inspection to Maya Chen. The queue and the Scheduler updated without a page reload. Salesforce refused the electrical inspection, and the job stayed in the queue. A record check confirmed that Pump inspection saved Maya Chen and Electrical inspection still had a blank technician.

**Read-only sandbox test.** Sign in as a user with Read permission and no Edit permission on Field Job. Select Electrical inspection, choose Tomas Berg, and click Assign selected job. In the sandbox, Salesforce rejected the save and Lightning displayed “entity type cannot be updated: Field Job”. Without reloading the page, Electrical inspection stayed in the queue and the same three jobs stayed on the schedule. A before-and-after check of the four Salesforce records confirmed that Electrical inspection stayed unassigned and the other jobs kept their technicians and time slots.

**Assignment with edit access.** Repeat the same assignment while Electrical inspection is still unassigned, using a user who can edit the job and its Technician field. In the sandbox, Lightning displayed “Job assigned.” Without reloading, the job left the queue and appeared under Tomas Berg in the Scheduler. The other three jobs stayed at their original times. A Salesforce record check confirmed that Tomas Berg was saved as the technician.

### Component references

* [Data Table](https://docs.avonnicomponents.com/lwc-components/data-driven-components/datatable)
* [Scheduler](https://docs.avonnicomponents.com/lwc-components/data-driven-components/scheduler)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/projects/use-cases/boards-and-pipelines/field-service-dispatch-queue-lwc.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
