I have a requirement to check the record type of a custom object being iterated over in a for loop (ContentDocumentLink) as part of an after insert trigger.
I have tried the following, assign Id variable to hold record type Id
Id RTId = Schema.SObjectType.Custom_Object__c.getRecordTypeInfosByName().get('Record Type Name').getRecordTypeId();
However, I am confused as to how to access the record type Id of the object instance in the for loop for when I do a conditional check in an if statement:
if( //Some Condition && **cd.LinkedEntityId.getRecordTypeId() !== RTId**)
{
PAIds.add(cd.LinkedEntityId);
documentIds.add(cd.Id);
}
I keep getting various compile errors depending on what I try, most recently "Method does not exist or incorrect signature: void getRecordTypeId() from the type Id" I'm sure it's some simple ignorance on my part of how to access from for loop object 'cd'.
cd.LinkedEntityId.RecordTypeId
orcd.LinkedEntity.RecordTypeId
in your if statement? I think one of these should work even though theLinkedEntityId
is polymorphic. Remember that RecordTypeId is a standard field on any object that allows record types. getRecordTypeId()` definitely will not work because it is only forRecordTypeInfo
.