You need to sign in to do that
Don't have an account?

Field_Integrity_Exception, you cannot create a link for this type of entity through the api:Linked Entity ID:[LinkedEntity] Cannot_Insert_Update_Activate_Entity
Hi,
We have a trigger on ContentVersion, whenever a record is created and file attached to that record, this trigger will copy the file to another custom object record.
The file is loaded from ccScan tool and we facing below issue. Any help is really appreaciated.
Thanks,
Naveen
We have a trigger on ContentVersion, whenever a record is created and file attached to that record, this trigger will copy the file to another custom object record.
The file is loaded from ccScan tool and we facing below issue. Any help is really appreaciated.
Trigger ContentVersionTrigger(after update) { ContentVersionHelper.onAfterUpdate(trigger.new); } public class ContentVersionHelper { public void onAfterUpdate(list<ContentVersion> clst) { set<id> cdids=new set<id>(); For(ContentVersion c:cLst) { Cdids.add(c.ContentDocumentId); } List<ContentDocumentLink> cdlst=[select id,contentdocumentid, LinkedEntityId from ContentDocumentLink where contentdocumentid in:cdids]; system.debug('#####cdlst='+cdlst); List<ContentDocumentLink> lst=new List<ContentDocumentLink>(); set<id> csids=new set<id>(); Map<Id,id> cseMap=new Map<id,id>(); for(ContentDocumentLink cd:cdlst) { csids.add(cd.LinkedEntityId); } system.debug('#####csids='+csids); List<Case__c> caseLst=[select id,legacyid__c from case__c where legacyid__c=:csids]; system.debug('#####caseLst='+caseLst); for(case__c c:caseLst) { cseMap.put(c.legacyid__c,c.id); } for(ContentDocumentLink cd:cdlst) { id myid=cd.LinkedEntityId; system.debug('#####myId='+myId); if(myId.getSObjectType().getDescribe().getName()=='ccScan__c') { ContentDocumentLink cDe = new ContentDocumentLink(); cDe.ContentDocumentId =cd.ContentDocumentId; system.debug('#####'+cseMap.get(cd.LinkedEntityId)); cDe.LinkedEntityId = cseMap.get(cd.LinkedEntityId); cDe.ShareType = 'V'; cDe.Visibility = 'AllUsers'; lst.add(cDe); } } insert lst; system.debug('#####lst='+lst); } }
Thanks,
Naveen
Feed Tracking is already enabled for this object.
Finally the issue is resolved. The problem is with the version of API.
Need to use the API version 33 and later. Changed the API to latest and issue is not seen.
In API versions 33.0 and later, you can create and delete ContentDocumentLink objects with a LinkedEntityId of any record type that can be tracked in the feed, even if feed tracking is disabled for that record type.
All Answers
Feed Tracking is already enabled for this object.
Finally the issue is resolved. The problem is with the version of API.
Need to use the API version 33 and later. Changed the API to latest and issue is not seen.
In API versions 33.0 and later, you can create and delete ContentDocumentLink objects with a LinkedEntityId of any record type that can be tracked in the feed, even if feed tracking is disabled for that record type.
Do we need to update api version latest to 33 or 33 to latest version please confirm I am a little bit confusing
API version must be greater than or equals to to 33.
Thanks!