You need to sign in to do that
Don't have an account?
Issue when adding a Note for a Case
I have this request body:
POST /services/data/v37.0/sobjects/Note HTTP/1.1 HOST: ap2.salesforce.com authorization: Bearer [ACCESS_TOKEN] content-type: application/json cookie: BrowserId=wBGf4rC3QK6IdvvndirVSQ content-length: 92
{"Title": "Test case note title", "Body":"Test case note body","ParentId":"5002800000T3Iu0"}
ParentId is a valid Case ID. But I get this as the response:
{
"message": "Parent ID: id value of incorrect type: 5002800000T3Iu0AAF"
"errorCode": "FIELD_INTEGRITY_EXCEPTION"
"fields": [1]
0: "ParentId"
}
Not sure what's wrong with the request params. I could successfully add Notes into Contact/Account.
Note in case is nothing but comments. Note is just filter to comments, if you add a note from ui you will see that it appears in comments. So insert a comment using the following code
CaseComment newCom = new CaseComment();
newCom.CommentBody = 'Testing Comment';
newCom.IsPublished = TRUE;
newCom.ParentId = '5002800000JLyWZ';
You can add Notes for Contact and Account but not for Case
All Answers
string pdfcontent = 'attachment';
Blob k = EncodingUtil.base64Decode(pdfcontent);
Attachment record = new Attachment(ParentId = '5002800000JLyWZ', Name='Anuja Testing'+'.pdf', Body = k,ContentType='application/pdf');
insert record;
Hope this will help you
I need a way of add a Note (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_note.htm) for a Case but not an attachment.
Note in case is nothing but comments. Note is just filter to comments, if you add a note from ui you will see that it appears in comments. So insert a comment using the following code
CaseComment newCom = new CaseComment();
newCom.CommentBody = 'Testing Comment';
newCom.IsPublished = TRUE;
newCom.ParentId = '5002800000JLyWZ';
You can add Notes for Contact and Account but not for Case
When doing this it enabled the ContentDocument for Attachments and Notes, instead of logging it into the CaseComment as listed above.
To create a Note from APEX the code below would works:
ContentNote newNote = new ContentNote(Title='Test Note');
insert newNote;
System.Debug('newNote: ' + newNote);
ContentDocumentLink newLink = new ContentDocumentLink(LinkedEntityId='CASEID' , ContentDocumentId=newNote.Id, ShareType='V');
insert newLink;
System.Debug('newLink: ' + newLink);
I attempted to do it used the Note object directly, but for Cases you get an error:System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Parent ID: id value of incorrect type: CASEID: [ParentId]
I am using the code above to get test execution on a trigger for the ContentDocumentLink object for when a note is put in the system it should update other items in the system.