You need to sign in to do that
Don't have an account?
Pooja Bisht 20
ContentDocumentLink returning only one record where LinkedEntity.Type = User
I am creating an enhanced note under Contact and adding the same note to another custom object called Custom Note while creating the note itself.
I have written After Insert trigger on ContentVersion where ContentDocument.FileType == 'SNOTE'. The issue here is that on quering ContentDocumentLink in trigger, the query is returning only one record where LinkedEntity.Type is User whereas using the same query in developer console, its returning 3 records, 1 for Contact, 1 for User and 1 for Custom object (Custom Note)
here is the code:
public void createTasksforEnhancedNotes(List<ContentVersion> notes){
Set<Id> noteIdSet = new Set<Id>();
for(ContentVersion each : notes){
noteIdSet.add(each.ContentDocument.Id);
}
if(noteIdSet != null && !noteIdSet.isEmpty()){
List<ContentDocumentLink> contentLinkList = [SELECT ContentDocument.Title, ContentDocumentId, LinkedEntityId FROM ContentDocumentLink
WHERE ContentDocumentId IN :noteIdSet];
}
}
Please help and explain why the query is returning different result in trigger and developer console
I have written After Insert trigger on ContentVersion where ContentDocument.FileType == 'SNOTE'. The issue here is that on quering ContentDocumentLink in trigger, the query is returning only one record where LinkedEntity.Type is User whereas using the same query in developer console, its returning 3 records, 1 for Contact, 1 for User and 1 for Custom object (Custom Note)
here is the code:
public void createTasksforEnhancedNotes(List<ContentVersion> notes){
Set<Id> noteIdSet = new Set<Id>();
for(ContentVersion each : notes){
noteIdSet.add(each.ContentDocument.Id);
}
if(noteIdSet != null && !noteIdSet.isEmpty()){
List<ContentDocumentLink> contentLinkList = [SELECT ContentDocument.Title, ContentDocumentId, LinkedEntityId FROM ContentDocumentLink
WHERE ContentDocumentId IN :noteIdSet];
}
}
Please help and explain why the query is returning different result in trigger and developer console
Can you try filtering your query as shown in the example and confirm if it returns the same results in your trigger and developer console?
Anudeep
I'm also facing the same issue,did you find the fix/ root cause for it? If yes can you please let me know what it is?