> 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/dynamic-components/component-builder/interactions/update-records-order.md).

# Update Records Order

The Update Records Order interaction persists a new display order for the records shown in a component.

## Overview

The Update Records Order interaction saves a new order for one or more Salesforce records — for example, after a user drags items into a different sequence. The new positions are written back to the field your query sorts by, so the order persists across sessions and users.

### Prerequisites

For this interaction to be usable, the component must meet two conditions:

* **Query data source**: The component must use a query data source.
* **Sortable items**: The component must offer the option to sort its items.

The records order field is the first field used in the ORDER BY clause of the component's query. When the interaction runs, that field is updated on the affected records to reflect the new order.

***

## Configuration

* Configure your component's query with the sorting field first in its ORDER BY clause (e.g., a numeric `Position__c` field).
* Enable the component's item sorting option.
* Add the Update Records Order interaction to the sorting trigger so the new order is saved to Salesforce.

### Post-Action Configuration

The interaction lets you chain follow-up interactions depending on the outcome:

* **On Success**: The interactions to execute when the records are reordered successfully — e.g., a [**Show Toast**](/dynamic-components/component-builder/interactions/show-toast.md) (Success variant) to confirm the change, or a [**Refresh Query**](/dynamic-components/component-builder/interactions/refresh-query.md) if other components display the same records.
* **On Error**: The interactions to execute when the order update fails — e.g., a [**Show Toast**](/dynamic-components/component-builder/interactions/show-toast.md) with the "Error" variant so the user knows the new order was not saved.

Accepted follow-up interactions for both outcomes are: [Show Toast](/dynamic-components/component-builder/interactions/show-toast.md), [Refresh All Queries](/dynamic-components/component-builder/interactions/refresh-all-queries.md), [Refresh Query](/dynamic-components/component-builder/interactions/refresh-query.md), [Get Record](/dynamic-components/component-builder/interactions/get-record.md), and [Assignment](/dynamic-components/component-builder/interactions/assignment.md).

***

## Example

Goal: Let users reorder a task list by dragging, and keep that priority order in Salesforce.

1. Query: The component queries Task records with `ORDER BY Priority_Order__c`.
2. Sorting: The component's item sorting option is enabled so users can rearrange items.
3. Interaction: Update Records Order writes the new positions to `Priority_Order__c`.
4. On Success: Show Toast ("Order saved"). On Error: Show Toast (Error variant).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.avonnicomponents.com/dynamic-components/component-builder/interactions/update-records-order.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
