Java 创建注释并将其附加到多个记录

Java 创建注释并将其附加到多个记录,java,sql,salesforce,apex,Java,Sql,Salesforce,Apex,我通过params发送id和消息的代码,但我需要一个与多个记录相关的注释,而不是每个记录的注释 public static void crearNotas(String casoid, String mensajenota){ //creamos notas para los casos relacionados System.debug('Nota creada para el caso: ' + casoid + 'con el mensaje: '+ mensajen

我通过params发送id和消息的代码,但我需要一个与多个记录相关的注释,而不是每个记录的注释

   public static void crearNotas(String casoid, String mensajenota){
    //creamos notas para los casos relacionados
    System.debug('Nota creada para el caso: ' + casoid + 'con el mensaje: '+ mensajenota);
    ContentNote objCntNote = new ContentNote();
    objCntNote.Title = 'Casos Relacionados';
    objCntNote.Content = Blob.valueOf(mensajenota);
    insert objCntNote; 

    //Creamos ContentDocumentLink hacia el id del caso
    ContentDocumentLink objCntDocLink = new ContentDocumentLink();
    objCntDocLink.LinkedEntityId = casoid; 
    objCntDocLink.ContentDocumentId = objCntNote.Id;  
    objCntDocLink.shareType = 'V'; 
    insert objCntDocLink;
}

谢谢:D

创建更多
ContentDocumentLink
记录。每个
ContentDocumentLink
都是链接对象和附加的注释或文件之间的连接点。
LinkedEntityId
是要将便笺链接到的记录的Id

如果调用者需要指定相关记录,请将
字符串casoid
更改为
列表
,并在其上迭代以创建链接。确保在
列表中创建记录
,并在循环外执行一次
插入
DML