There seems to be some unusual stuff going on with SObjectType
for the enhanced note ContentNote
(ERD) object and the underling ContentDocument
(ERD) structure.
For example, both these return a single row (with the Id taken from an enhanced note I created);
select Id from ContentDocument where Id = '069R00000002J0m'
select Id from ContentNote where Id = '069R00000002J0m'
and these both return "069":
System.debug(Schema.getGlobalDescribe().get('ContentDocument').getDescribe().getKeyPrefix());
System.debug(Schema.getGlobalDescribe().get('ContentNote').getDescribe().getKeyPrefix());
and this:
System.debug(((Id) '069R00000002J0m').getSObjectType());
outputs ContentDocument
.
This turns out to be quite awkward for a change to some existing code that I am making, in that AFAIK the only way to generically identify an enhanced note versus a File attachment is to check that the ContentDocument.FileType
has the value "SNOTE". As far as triggers and SObjectType
based logic is concerned, ContentDocument
is the type.
Please share any insight you may have on what is going on here so that I make my code changes in the cleanest way.
ContentDocumentLink
that only does something if it is tied to a ContentNote. I would prefer to not do the answer below even though it will work.