Build Relationships from Events or Tasks to a Related Custom Object
Activities such as Events and Tasks are unique. If Task or Events is your starting object, you could run into trouble building relationships to related custom objects.
In this use case, our starting object will be Event. The Event is on the Activities related list located on a custom object, which we will call “Albums”. Our goal is to pull in data (Name and Text Area) into our generated document from field that lay on the “Album” object.
Because fields on the look up fields on the Event object are technically “Related To” fields, we will need to us a SOQL query to bring in the need information.
Notes for the Scenario: Event record name is “Tests” Album record name is “Daybreaker”
Look at the picture below. The “Related To” field holds a link to the Album we are trying to pull in.
Now let’s take a look at the API names of the fields on the same Event record. Notice that the Related To field has an API name of “WhatId”. When building our SOQL, we will look for the WhatId tag in our field tagger for the “WHERE” portion.
Next, we will determine the fields we want to bring in. In this scenario, we want to pull in the fields “Name” and “Text Area”
Finally, we will build our SOQL. Here is an example SOQL:
SELECTInsert desired fields hereFROMInsert object name where fields are coming fromWHERE Id = Insert tag for field that holds object we are trying to pull data from
Here is the SOQL used for the scenario in this article:
SELECT Name, Text_Area__c FROM Album__c WHERE Id= '<<Event_What_Id>>'
Lastly, navigate to the field tagger. In our scenario, the Main object will read as “Album (SOQL)”. This is where we will find our tags.
If we are trying to pull in a field that is a lookup on the Album record, we will have to use Dot notation. Example: There is a look up to the Artist on the Album record. To pull in the Artist name, we will use Artist__r.name