You need to sign in to do that
Don't have an account?
Nathan Prats 22
Test Class on ContentDocumentLink Trigger
Hello,
I created this trigger which set a share type for each new content document link.
But I receive this error:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, ContentDocument ID: id value of incorrect type: 0683E0000003EXVQA2: [ContentDocumentId]
Any idea why ?
I created this trigger which set a share type for each new content document link.
trigger ContentDocumentLinkTrigger on ContentDocumentLink (before insert) { for(ContentDocumentLink cdl: Trigger.new){ cdl.shareType = 'I'; } }I tried to create this test class:
@isTest public class ContentDocumentLinkTriggerTest { @isTest static void ContentDocumentLinkTriggerTest() { // Create a ContentVersion ContentVersion ContentDoc = new ContentVersion(); ContentDoc.Title = 'My Doc'; ContentDoc.ContentUrl= 'test.com'; Insert ContentDoc; // Create a ContentDocumentLink ContentDocumentLink ContentDL = new ContentDocumentLink(); ContentDL.ContentDocumentId = ContentDoc.Id; Insert ContentDL; // Verify the share type is = i System.assertEquals(ContentDL.ShareType,'I'); } }
But I receive this error:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, ContentDocument ID: id value of incorrect type: 0683E0000003EXVQA2: [ContentDocumentId]
Any idea why ?
1) https://developer.salesforce.com/forums/?id=906F0000000AbR9IAK
Update your code like below Let us know if this will help you
All Answers
To create content document try below,
https://developer.salesforce.com/forums/?id=906F0000000AbR9IAK
1) https://developer.salesforce.com/forums/?id=906F0000000AbR9IAK
Update your code like below Let us know if this will help you
It passed like this :