Skip to main content

How can I filter a table based on State and Country Picklists introduced in Winter 2014? e.g. a table showing accounts.

I don’t find any State or Country SObject for which I could create my model of.

We do not think Salesforce is actually using an sObject for the shared state and country picklist values.  There is trickery afoot there. 
You can however create a filter on the picklist values in several ways.   You should check out the cheat sheet we published on filters

If you are ok with users selecting from all the possible picklist values present in your metadata,  create a condition on the state or country field and then in your filter make the source “PIcklist Values”

If you want users only to choose from the values that have been entered in your data - you can use an aggregate model to build that list,  and use the source type “Field from another model” to populate your drop down box.  That is explained in use case #6 in the cheat sheet document. 

There are also ways you could create depenedent picklist scenarios so the filter only has states from a particular country.  
1. Create a dummy model that includes the country field.  In the advanced property of the model this should be set to “create new row” and not “load data”.   Also make sure this model is not saved back to the server.  This is really just data that needs to exist client side for building the right filter.  Build a field editor with this field so a user can select a country above the table.   
2. Build an aggregate model that groups by the state field.  (this is use case #6 above).  In the conditions for this model create a “field from another model” condition lookin at the model we created in stsep 1.  This will only let the aggregation of state occur on rows where the country is what the user selects. 
3 This aggregate model of filtered states then becomes the source for the filter values on your table. 

This seems like a hack - but it should work.  There are other ways you could get this to work as well… 


Reply