LinkedEntityId from the ContentDocumentLink is not always populated in Before Trigger

So I have a trigger (Before insert, on ContentDocumentLink) which is part of Managed Package and is not throwing Null Pointer Exception.Upon inspection, I found that this line is where the null pointer exception is happening.

for (ContentDocumentLink contentdoclinkItr : Trigger.new) {
    String sObjectName = contentdoclinkItr.LinkedEntityId.getSObjectType().getDescribe().getName();
}

My deduction is that the LinkedEntityId is not populated because in the log I can't see the Field.

VARIABLE_SCOPE_BEGIN|[2]|cdl|ContentDocumentLink|true|false
VARIABLE_ASSIGNMENT|[2]|cdl|{"IsDeleted":false,"Visibility":"AllUsers","ContentDocumentId":"0694g000000aE6gAAE"}

we can see fields like IsDelete, Visibility, ContentDocumentId but no Field entry of LinkedEntityId.

Поскольку это часть управляемого пакета, поэтому я не могу его изменить, поэтому я реплицировал код этого триггера в новый триггер, чтобы увидеть поле LinkedEntityId в журнале.

VARIABLE_SCOPE_BEGIN|[3]|cdl|ContentDocumentLink|true|false
VARIABLE_ASSIGNMENT|[3]|cdl|{"IsDeleted":false,"LinkedEntityId":"0054g000000XvyEAAS","Visibility":"AllUsers","ContentDocumentId":"0694g000000aE6gAAE","ShareType":"I"}

0 ответов

Другие вопросы по тегам