You need to sign in to do that
Don't have an account?
ManojKumar Muthu
Apex Code for to list view all notes related a Case.
Hi All ,
Hi,
I am trying to list all case created to particular account here the parameter is the CaseId, below the apex code,
below the code,
RestResource(urlMapping='/NotesListView/*')
global with sharing class NotesListView{
@HttpGet
global static List<Note> getNoteById() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String Id= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
List<Note> result = [Select Id, Title, Body from Note where ParentId= :Id];
return result;
}
}
Where I Pass CaseId in ParentId.
Hi,
I am trying to list all case created to particular account here the parameter is the CaseId, below the apex code,
below the code,
RestResource(urlMapping='/NotesListView/*')
global with sharing class NotesListView{
@HttpGet
global static List<Note> getNoteById() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String Id= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
List<Note> result = [Select Id, Title, Body from Note where ParentId= :Id];
return result;
}
}
Where I Pass CaseId in ParentId.
---------------------
RestResource(urlMapping='/NotesListView/*')
global with sharing class NotesListView{
@HttpGet
global static List<ContentDocumentLink> getNoteById() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String Id= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
List<ContentDocumentLink> result = [SELECT ContentDocumentId,ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId=:Id];
return result;
}
}
--------------------------------
Please mark it best if it helps you. Thanks.
All Answers
Select Id, Title, Body from Note where ParentId= 'YourCaseID'
---------------------
RestResource(urlMapping='/NotesListView/*')
global with sharing class NotesListView{
@HttpGet
global static List<ContentDocumentLink> getNoteById() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String Id= req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
List<ContentDocumentLink> result = [SELECT ContentDocumentId,ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId=:Id];
return result;
}
}
--------------------------------
Please mark it best if it helps you. Thanks.
// query where CaseId='5003C000001cdzr'
SELECT ContentDocumentId,ContentDocument.Title FROM ContentDocumentLink WHERE LinkedEntityId='5003C000001cdzr'
Select Id,VersionData from ContentVersion where ContentDocumentId='ContentDocumentId'
VersionData(from the second query) will give you the body of the Note.
To get the Body as text string use below code.
String afterblob = EncodingUtil.base64Encode(VersionData);