How Can I Sort Contacts by Campaign as in SF Contact Views? Where it gets tricky is the Campaign Member object is the connector between Contacts and Campaigns, so I can’t quite figure out how to set up a filter on a Squid Contact Tab. Any pointers?
Hi Krista, This is somewhat tricky, but it is doable! If you just want to skip right to a working example, go to the bottom and copy/paste the XML into a new Skuid Page’s XML (See this tutorial for how to copy/paste/share Skuid Page XML) Here’s the end product, a page where you can filter your contacts to just those that are a member of any Campaign, and then optionally select a particular Campaign that they must be a member of: Here’s how this is done: 1. Create a Model on the Campaigns that you want to Filter on
2. Create a Sub-query Condition on your Contacts model to allow you to filter to show just Contacts that have CampaignMember records for a particular Campaign:
Here you will have to create 2 Conditions, both with State = “Filterable (Default Off)”, and both with unique names. The parent condition should be called “MemberOfACampaign”, and be of type “Result of a Subquery”, with Join Object = “CampaignMember” and Join Field = “ContactId”. Once you’ve created this Condition, add a Sub-Condition on the CampaignId field, again Filterable (Default Off), with Name “CampaignId”. 3. Create 2 Filters on your Contacts Table
Filter 1: Label: “Require Contacts to be a member of a Campaign”. Type: Toggle Effects: Activate the MemberOfACampaign condition. Filter 2: Filter Off Option Label: “Select a Campaign…”. Type: Select Option Condition: CampaignId Add a single Source, of type “Model”, on the Campaigns model, and you can ignore Label Template and Value Template. **If you want, for this page, to ONLY ever show Contacts that are a member of a Campaign, then you can change the “MemberOfACampaign” condition to be “Always On”, and can remove Filter 1 (called “Require Contacts to be a member of a Campaign”. working example Skuid Page:
Zach this is great! Thanks. I’m guessing that Krista is probably going to want to add another condition to the Campaign model that limits campaigns that are active using the “is active” or “status” fields. Otherwise over time the drop down list is going to get LOOOOONG…
Rob, You read my mind. Only . . .where do I add that model/filter since we would need to filter on the Campaign Status field and the filter Zach built is on the Campaign Member. The Campaign Status field is on the Campaign object. I don’t know how to get from here to there from a condition- filter perspective. Also, a random question from left field: can one filter on Tags in Squid or pull up tagged Contact records in a Skuid page Thanks!
The above produced an error with the toggle filter option. Apex heap size too large: 6199207. We have an usually large database (359,982 contacts). To avoid the issue , I turned off the toggle following your instructions to show only those Contacts that are campaign members. I changed the “MemberOfACampaign” condition to be “Always On”, and removed Filter 1 (called “Require Contacts to be a member of a Campaign”. So, good news, the page loads without the Apex heap too large error. However, when I attempt to select a Campaign, nothing appears when I type in the name of the Campaign in whole or in part. Thoughts?