Move selected item to top of queue

  • 1
  • Problem
  • Updated 2 years ago
  • Solved
I am attempting to have ti so that when you click on an item in a queue it moves to the top of the queue.  I have created a checkbox on my object called Pinned (pinned__c) and have the following queue item actions:
  • Show Message and Block UI
  • Update a Field on Row (Pinned__c=TRUE)
  • Save Model Changes
  • Query Model
  • Unblock UI
  • Run Snippet (the snippet performs Update Page Include)
The model is sorted by Pinned__c.  The box will show as checked on the Page Include, but not on the queue (so the selected item in queue doesn't go to the top).
Photo of Curtis Ellingham

Curtis Ellingham

  • 362 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Vivek Gupta

Vivek Gupta

  • 378 Points 250 badge 2x thumb
The sequence of action should be - 
Update a field value  (pinned_c = true)
Requery model
If your model has order by pinned asc/dsc, this should move selected item to top.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Vivek,

Curtis will get an error if he attempts to query after updating. You can't query a model with unsaved changes.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Curtis,

Try running a one-line snippet like this right after your query action:

skuid.$C('MyQueueComponentId').render();

Replace MyQueueComponentId with whatever the Unique ID of your queue component is.

Does that work?
Photo of Gregg Baxter

Gregg Baxter, Official Rep

  • 3,080 Points 3k badge 2x thumb
Hi Curtis

I used the Account Object as a test.  I added a a checkbox field to the object.

I created a Skuid page with the Accounts Model in it and added 'Pinned__c DESC' in the 'fields to order records by' model properties.

In the Queue properties 'Item Action' I set the 'Item On-Click Action Type' to multiple actions.

On the 'Actions' property I added:

FIRST ACTION
Action Type = Update a field on row(s)
Model = 'MyModel' (in my case AccountMod1)
Field = Pinned__c
Value = √

SECOND ACTION
Action Type = 
Save Model Changes
Model to Save = AccountMod1

THIRD ACTION
Action Type = Query Model
Model = AccountMod1
Query Behaviour = Standard-Completely Replace Data

This brings all the pinned models to the top.
Photo of Curtis Ellingham

Curtis Ellingham

  • 362 Points 250 badge 2x thumb
That worked, thanks
Photo of Gregg Baxter

Gregg Baxter, Official Rep

  • 3,080 Points 3k badge 2x thumb
Very welcome.

Happy Skuiding!