You need to sign in to do that
Don't have an account?
sauravsharma001
Not able to query the inserted case.
I have created one REST API in Apex which takes paramters and create a case and in return I have to send Case Number of the created case. The problem is when I am trying to query the case object with the help of the case id generated in insert query, I am getting this error : List has no rows for assignment to SObject
@HttpGet
global static String doGet() {
Case c = new Case (
Subject = 'Test',
Status = 'New'
);
Insert c;
System.debug('Case ID: ' + c.id);
Case newCase = [Select id, CaseNumber from Case WHERE id =:c.Id];
return (String.valueOf(newCase));
}
@HttpGet
global static String doGet() {
Case c = new Case (
Subject = 'Test',
Status = 'New'
);
Insert c;
System.debug('Case ID: ' + c.id);
Case newCase = [Select id, CaseNumber from Case WHERE id =:c.Id];
return (String.valueOf(newCase));
}
James Loghry
What does your OWD (Sharing settings) look like for cases? Are they set to private? I'm curious if the Case is routed to some other person, and thus hidden from the person calling the webservice. Have you tried adding without sharing to the class just to see what happens?