I have a lookup reference field on Account that returns the looked up values from a custom object (Stage__c) in a picklist (which makes sense, as there are only 20 or so records in the looked up object). But I want the picklist entries to be in a sort order based on another field on Stage__c called Sort_Order__c. I can’t find how to do that. Is there a magic way that I’m missing?
- Go create a “Stages” Model, and order it by Sort_Order__c.
2. Go to your field’s “Advanced” properties, you’ll see an “Option Source” property. If you set this to Model, rather than Automatic, then you get an “Option Model” property. Select your Stages model. Skuid will then use your Stages Model as its source of lookup/reference field entries, rather than the “Automatic” Model that Skuid auto-generates. And the records will be ordered by Sort Order.
Thanks Zach. I knew it was something simple like that.
Hey Zach -
Aside from using a separate model, is there any metadata property (e.g. field.options.???) that would force the SOQL generated for the lookup field to use a different order by clause other than Name?
We have several of these situations on a page so we’d end up having to define several more models to accomplish when we really only need to specify the order by clause.
Assuming we have to use a model for now, would be a welcome enhancement to be able to declaritively specify the order by clause on lookup fields.
Thanks!
Via JavaScript, if you set field.options.order , this will be used instead of “Name” as the Order for the automatic source, e.g.
field.options.order = ‘StageName, CloseDate DESC’;
For more info see the API Docs for the REFERENCE Field Renderer: http://help.skuidify.com/m/11720/l/214147-skuid-ui-field-renderers
Thanks Zach. This works well for us since we already have a custom renderer for most of these fields. Would love to see sort order added to declaritive lookup filter options in a future release!
And Kudos to the team on the docs, awesome to see the improvements!!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.