Custom picklist renderer to remove duplicates

Hi team!

I am rendering picklist values from a model as option source on a reference field using Skuid’s default picklist field renderer (so far, so good).

Due to the nature of the option source model, multiple entries show up in the picklist which are unique records in the model, but duplicates based on my display criteria.

I would like to:

  1. Remove the duplicate from the picklist if there are 2 identical display values
  2. Remove the option altogether from the picklist if there are 3 or more identical display values

How would I go about achieving this?

My sense is that the solution might be an extension to these posts:

This is unfortunately beyond my skillset though, so I was hoping that someone here might be able to point me in the right direction :slight_smile:

Thank you in advance!



It is for selecting available time slots and avoid overbooking. In this example, I would like to remove the second instance of the “15/02/2019 9:45 am”

I have done this by doing what you are doing, except use a Model of type Aggregate to be your source instead of a basic model.  In your aggregate model, group on your time slots fields - and this will create one entry per group, instead of the repeats like you are seeing in a basic model.  Then set your picklist source to be the grouped field name - you’ll have to use the alias name that gets created on the group instead of the actual field name. So, after you create your aggregate model and group on Time_Slot__c (not sure what your field is called) the alias will be something like timeslotc and you use that for your picklist source.

Hi Chandra, Ok excellent! That’s amazing, will try that. Thanks so much! This probably solves most of it already. Do you or does anyone have thoughts regarding how I would go about requirement 2)? That is removing entries if there are 3 or more instances. Could this be done with some model condition? Love the community :slight_smile: Robin

Hmmmm yes… but it requires a little hacking into the xml.  You can read this post and see if you want to venture there!

Ok thanks again, Chandra! Who doesn’t love a bit of xml hacking in the morning…? :slight_smile:

I’ll see how I go with this, will take me a couple of hours until I can get to it though unfortunately. Really appreciate your response and you sharing your knowledge!

Ok so I’ve experimented with the aggregate model solution, and it kind of works, which is more than I had before I started, so we’ll call it a win :slight_smile: It indeed “de-duplicates” the values and displays them neatly in my option picklist on the reference field. Thanks for the great suggestion, Chandra!

Now to the nitty-gritty:

1) My appointments are 4 slots per hour (every 15 minutes), and the most granular grouping on the datetime field seems to be “HOUR_IN_DAY”, and the limitation of the aggregation of the datetime field only allowing “MIN” and “MAX” functions. This means that I only ever get 1 option of the total possible 4 as a picklist value (depending on whether I’m rendering the MIN or MAX aggregate field), so let’s say 3pm or 3:45pm for that hour, but not the others. 

Am I missing something obvious? How can I display ALL results for HOUR_IN_DAY or hack the HOUR_IN_DAY to be more granular? Is there a MINUTE_IN_DAY that is not available from the dropdown by default? (the org is on 10.x Brooklyn version of Skuid)

2) I have not yet experimented with the xml hack due to the hiccup above, so if anybody in the meantime would have suggestions how to solve it with a custom field renderer, that would be greatly appreciated!

Best regards, 


Unfortunately it looks like this is a limitation of salesforce/soql:…

You may have to go back to the basic model approach the brute-force the grouping (run javascript after the model is loaded to remove any duplicates).

Thank you Matt! Ok sometimes it’s good to know it’s a dead end. Still disappointing through of course :wink: I’m unfortunately out of my depth with JavaScript on this. Would you or someone else be able to give me some pointers how I’d go about it? Much appreciated and keep skuidding! Robin