Event Relation to show Deeper WhoId (always a contact or user) Information Table

  • 1
  • Question
  • Updated 2 years ago
  • Answered
On event we have the ability to add multiple contact or user object records using the eventRelation object in the form of a related list.

I wish to be able to display a table that shows all of the contacts related to the event in a table, and be able to display the contact name, associated account, and various account fields.

I've tried to create a model to handle this, but it doesn't seem to be pulling through the correct records.....any ideas?

Below is an image of how i'd like it to look. 
Photo of Glenn Daly

Glenn Daly

  • 1,270 Points 1k badge 2x thumb

Posted 2 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Yup. The RelationId is a polymorphic field. You won't be able to get fields from Contact, Lead or User using it without the use of a formula field for each field you'd like data on. The premise works on creating 3 support models that have all your attendees. Contact, Lead and User. Then you can use modellookup formula to get the fields you want into your EventRelation model.

Support formula of type text for prefix:
RelationTypePrefix:
Left(RelationId,3)

Example on UI only formula field for First Name:
If({{RelationTypePrefix}}=='003',
modellookup('ContactAttendees','FirstName','Id',{{RelationId}}),
NestedIfforLeadandUserHere)

Rinse and repeat for the remaining fields.
Photo of Glenn Daly

Glenn Daly

  • 1,270 Points 1k badge 2x thumb
Thanks very much, probably being a tad thick because it's Friday, but do the models containing contacts need to be eventrelation records,  if you know what I mean? And then  what condition do i need to have from my "Contacts" model to eventrelation model?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You will use the Contact, Lead and User object models with conditions like the following;

Id in EventRelationModel.RelationId

Make sure you place these models after EventRelationModel, otherwise the conditions won't work.