Skip to content

Obsidian Dynamic Data merge output ignores the grid's row order #6997

Description

@booneboy94

Description

The Obsidian Dynamic Data block does not preserve its sorted row order when it creates the temporary EntitySet used by the Merge Template grid action.

This was reproduced on the official Rock demo with four stock people. The SQL query and displayed grid are ordered by LastName, NickName, and Id. The Merge Template page's Show Data Rows preview contains the same people in a different order before a merge template is selected.

The client builds the entity-set payload from grid.sortedRows and assigns each GridEntitySetItemBag an incrementing order:
https://github.com/SparkDevNetwork/Rock/blob/19.3.4/Rock.JavaScript.Obsidian/Framework/Core/Controls/grid.ts#L633-L768

GridHelper.CreateEntitySet() copies EntityId and AdditionalMergeValues but does not copy that order to EntitySetItem.Order:
https://github.com/SparkDevNetwork/Rock/blob/19.3.4/Rock/Obsidian/UI/GridHelper.cs#L58-L99

EntitySetService.GetEntityQuery() then orders by EntitySetItem.Order and falls back to Person ID:
https://github.com/SparkDevNetwork/Rock/blob/19.3.4/Rock/Model/Core/EntitySet/EntitySetService.cs#L123-L165

Since every persisted item order has its default value, the requested grid order is lost. The same omission is present on the current develop branch:
https://github.com/SparkDevNetwork/Rock/blob/develop/Rock/Obsidian/UI/GridHelper.cs

Suggested fix: Copy GridEntitySetItemBag.Order to EntitySetItem.Order in both branches of GridHelper.CreateEntitySet().

Dynamic Data grid (alphabetical order):

Image

Actual Behavior

The visible Dynamic Data grid is ordered Alex, Cindy, Noah, and Ted Decker. After opening the Merge Template action, Show Data Rows changes the same records to Ted, Cindy, Noah, and Alex—Person ID order for these stock records. The SQL and visible grid order do not survive the Obsidian EntitySet handoff.

Merge preview (incorrect order):

Image

Expected Behavior

The Merge Template page and generated document should preserve the row order supplied by grid.sortedRows. For this reproduction, the records should remain ordered by LastName, NickName, and Id: Alex, Cindy, Noah, then Ted Decker.

Steps to Reproduce

  1. On the official demo site, add an Obsidian Dynamic Data block to a temporary internal page.

  2. Configure the block for Grid output:

    • Set the Id column type to Person and hide it from the grid.
    • Enable Person Report.
    • Enable the Merge Template grid action.
  3. Use this query:

    SELECT p.Id, p.NickName, p.LastName
    FROM [Person] AS p
    WHERE p.Id IN (6, 7, 8, 9)
    ORDER BY p.LastName, p.NickName, p.Id;
  4. Load the page and confirm the visible order is Alex, Cindy, Noah, and Ted Decker.

  5. Open the grid's menu and select Merge Template.

  6. Select Show Data Rows.

  7. Observe that the preview order is Ted, Cindy, Noah, and Alex.

The reproduction made on 2026-08-26 used demo Page 906 / Block 1650. The public demo periodically resets, so those IDs may not remain available.

Issue Confirmation

  • Perform a search on the Github Issues to see if your bug is already reported.
  • Reproduced the problem on a fresh install or on the demo site.

Rock Version

19.3.4

Client Culture Setting

en-US

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions