I am writing a very simple plugin which creates Contact and associate a note to it. I noticed that to add a note to a contact, I should first create the contact after that add the note here is my simple code divided it into two steps:

1- Create the new Contact Record

        Contact NewContactRecord = new Contact();
                NewContactRecord.FirstName = Result.name;
                NewContactRecord.Email = Result.email;
                NewContactRecord.Phone = Result.phone;
                NewContactRecord.Title = Result.job;
SaveResult[] CreatedContact = _SForceRef.create(new sObject[] { NewContactRecord });

2- Associate the Contact with the note

 if (CreatedContact[0].id!=null)
                    Note Notes = new Note();
                    Notes.Title = "Note Title";// Result.notes;
                    Notes.Body = "Note Body"; //Result.notes;
                    Notes.ParentId = CreatedContact[0].id;
                    Notes.IsPrivate = false;
                    SaveResult[] CreatedNote = _SForceRef.create(new sObject[] { Notes });
                    if (CreatedNote[0].success)
                        textBox1.Text = string.Format("Is The note created={0}" , CreatedNote[0].success);
                        textBox1.Text = CreatedNote[0].errors[0].message;

It always gives me that the note is created but I didn`t see it neighter linked with the contact nor at Notes Entity

  • 2
    please take the time to format your post next time =) . and welcome to SFSE! – glls Oct 17 '18 at 13:15

Your code appears to be correct; I tested similar code in my developer org. I think your issue has to do with object access and display.

Salesforce has two systems for attaching Files and Notes to records.

The newer system uses a group of objects whose names start with Content, such as ContentDocument (an attached file) and ContentNote, an attached note.

The older system uses the Note and Attachment objects, as you're using here.

Depending on the configuration of your Salesforce org and specifically its related lists, you may not see older-style Note and Attachment records at all. Here's an example screenshot:

enter image description here

Note records appear only in the "Notes & Attachments" related list (which shows Note and Attachment sObjects), but not in the "Notes" related list (which shows ContentNote sObjects). Similarly, the "Files" related list shows ContentDocument sObjects, and Attachment records show only in "Notes & Attachments".

It's recommended that newer code always use the Content objects, as this is the direction of development for Salesforce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.