3

Our client wants to use the standard Contact List View functionality to display Lists of Contacts.

Let's say that there needs to be a List View called 'My Special Contacts'. The way to determine a 'Special Contact' is through a Custom Object, UserSpecialContacts__c which has a lookup to a user and a lookup to a Contact.

The logic for the My Special Contacts should therefore something like

List<Contact> c = Select Contact__c from UserSpecialContacts where User__c = (current running user).

Now, it looks as though I cannot achieve this through Salesforce filter logic etc. I understand that it may be possible as a report, but is there any way I can make this happen so that it appears as a list view? I can use Visualforce Pages if necessary, but rewriting the whole List View page is probably not an option so I would need to extend an existing component.

  • Just thinking aloud, a formula field on Contact - UserSpecialContact__c, which does a VLOOKUP on the UserSpecialContacts Object based on the $User. It will evaluate to true based on User. Add that to List view and then filter on this field. – techtrekker Nov 6 '12 at 14:26
  • VLOOKUP has to match against Name only :] And even if we'd populate Name with user's name - it can be used only in Val. Rules. Awesome question :D – eyescream Nov 6 '12 at 14:30
2

I'm afraid you have to create a VF page and use it as a custom VF tab (since you can't even override the Contacts Tab).

Sir, it's an awesome question cracks me up that we can't do such a simple thing :) Does it really have to be a related object that drives the logic? Won't a (multiselect) picklist on Contact do, as nasty as it sounds in terms of maintenance?

EDIT: 3 more ideas:

  1. You can build listview filter on contacts using a Campaign (I won't be surprised if it works for only when you have "Marketing User" ticked) - would that work?
  2. Would it work for you to enable tags (maybe only personal tags)? They're still fairly easy to search from sidebar/global search and look like working with them is less hassle than inserting new entries on a related list. Maybe even combine it with a list view button for mass add/remove tags...
  3. Similar one about following them with Chatter?
| improve this answer | |
  • You could always write (the Username) to a field on the Contact record via a trigger, if the user is okay to filter by their own name (contains) ! – techtrekker Nov 6 '12 at 14:44
  • Initially I thought the comment above would solve the problem, then I read in the docs "You can't use standard or custom long text area fields for filter criteria in list views." I'm imagining this field would get a lot bigger than 255 characters :| – George S. Nov 6 '12 at 14:57
  • Maybe you could put user Ids or make sure aliases will be always unique? Up to 16 values: 16 * 15 IDs + 15 spaces = 255 – eyescream Nov 6 '12 at 14:58
  • Its just a matter of how many Users a Contact is 'Special' too ! ;) If you've got Account Relationship Managers, then prolly not that many per Contact. Or maybe not. Depends on your organisation. – techtrekker Nov 6 '12 at 15:56
  • There's probably going to be a lot but I can't know for sure. Of course, I can create multiple TextAreas to contain more than 16 IDs and do an OR in the filter logic, but it's a pretty disgusting solution. – George S. Nov 6 '12 at 16:38
0

One thing you could do is make the lookup to Contact from UserSpecialContacts Master-Detail, That way you can create a Roll-Up-Summary field on Contact for example:

  • Create Roll Up Summary Field: count_special_contacts__c (which just counts the amount of special contacts)

  • then in your filter of the list view you can create where count_special_contacts__c greater than 0

This way your view will only show contacts which has at least 1 special contact as child record

Your other option is writing the visualforce page or use a report

| improve this answer | |
  • I think it won't work. It has to be dynamically based on current user and you can't put anything dynamic into rollups ($User, TODAY etc) because they recalculate only insert/update happens. – eyescream Nov 6 '12 at 14:16
  • Oh right, I didn't read well, it's based on the current logged in user. What you could do is, create the list view as "MY Contacts" since you are using master-detail, the owner of the specialcontact record is the same as the contact record. This way only the logged in user's contacts are shown in the list view – pjcarly Nov 6 '12 at 14:19
  • But it clearly shows he already has a lookup on the child obj, User__c ;] Sorry if I sound negative, interesting one but I doubt it can be done. It would have to be listview of UserSpecialContacts, not of Contacts (and even then there would be no catch-all simple view "My UserSpecialContacts" because of the M-D. – eyescream Nov 6 '12 at 14:23
  • If he want's to use the User__c on SpecialContact than it won't be possible, (no problem about the negativeness, I can handle it ;)) I was hoping perhaps the roll-up would somehow match his need, if it doesn't than Report/Visualforce will be the way – pjcarly Nov 6 '12 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.