This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Insert case record | |
Case cs = new Case(Name='Installation Issue', Origin='Web'); | |
Insert cs; | |
//Create Document | |
ContentVersion cVersion = new ContentVersion(); | |
cVersion.Title = 'Doc'; | |
cVersion.PathOnClient = 'Doc.docx'; | |
cVersion.VersionData = Blob.valueOf('Issue with Installation'); | |
cVersion.IsMajorVersion = true; | |
Insert cVersion; | |
//Fetch Content Documents | |
Id conDocId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cVersion.Id].ContentDocumentId; | |
//Create ContentDocumentLink | |
ContentDocumentLink cdLink = New ContentDocumentLink(); | |
cdLink.LinkedEntityId = cs.Id; | |
cdLink.ContentDocumentId = conDocId; | |
cdLink.shareType = 'V'; | |
Insert cdLink; |