+ Start a Discussion

Easy question: what is the Apex name for Activity Record Type?

SFDC Support build us a  custom trigger that is not doing it job and they are not wanting to make any changes to it now. All I need to know to make the changes is what is the correct name of the field that would be typed into Apex coding for Activity Record Type (Task, Event, Null).


In the bigger picture, where are the Apex code names of all fields located?


Thanks in advance!


The name of the field used in Apex code is the same as that used with the API. Find this for any field by viewing its details (click on the field listed under the Setup menu). For custom fields, you'll want the value in the API Name field. For standard fields, you'll use the value in the Field Name field.


The issue Im having is that Activity Record Type is not a field per say, so under Setup I cannot find what the Apex or API name would be. I tried "a.RecordType" because for example "a.Subject" is the name of the email subject and that did not work.


Record Types are a distinct object.


To assign a Record Type to a Task record, you need to set the RecordTypeId field to the ID of the appropriate Task Record Type. The name of the field to use when assigning record types to records is always RecordTypeId, regardless of the object you are setting it on.


To find the right RecordTypeId to set on your Task you'll either have to 1) query the RecordType object to obtain the Id for the Record Type with filter SobjectType = 'Task' and Name = 'whatever', or 2) look up the Id by clicking on its details under setup (the Id will be in the URL).