function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Thomas MuradThomas Murad 

How insert ID into fields

I want to know how i can take id of comSF and put in my fields CommentSF_Id__cUser-added image
Best Answer chosen by Thomas Murad
Maharajan CMaharajan C
Hi Thomas,

While you inserting the record Salesforce will not allow you to declare the Id for the record. Record Id will be generated by Salesfroce automatically on Insertions.

If you want to link these two case comment create a custom field where you have to populate the  CommentNB.CommentSF_ID__c   to track the related case comments.

Thanks,
Maharajan.C

All Answers

Thomas MuradThomas Murad
List<CaseComment> ComListSF = new List <CaseComment>();    
            // Commentaires de SF = Nouveau commentaire SF via les informations de la table NB
            CaseComment comSF = new CaseComment (CommentBody = CommentNB.CommentBody__c, IsPublished = CommentNB.Public__c , ParentId = CommentNB.ParentID__c );
            // Ajoute le Commentaire comSF dans la liste de commentaire ComListSF
            comSF.Id = CommentNB.CommentSF_ID__c;
            ComListSF.add(comSF);  
            insert ComListSF; 
Maharajan CMaharajan C
Hi Thomas,

While you inserting the record Salesforce will not allow you to declare the Id for the record. Record Id will be generated by Salesfroce automatically on Insertions.

If you want to link these two case comment create a custom field where you have to populate the  CommentNB.CommentSF_ID__c   to track the related case comments.

Thanks,
Maharajan.C
This was selected as the best answer