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
Keith Stephens 18Keith Stephens 18 

create a class to call soql and pass json to my rest service

Hello All,
How do I write a simple Salesforce class that will execute this soql "SELECT LastModifiedDate,Plaintiff_Full_Name__c,Plaintiff_Last_Name__c FROM Case limit 3"
And return a Json string so I can pass that to my C# rest service.
And for testing sake call the class from the Developer Console.

Thanks for any help, I am learning SF as I go.
Keith.
ranjith thadakala 3ranjith thadakala 3
@RestResource(urlMapping='/any name/*')
global with sharing class mycls {
    
    @HttpGet
    global static List<Case> getRecord() {
        List<Case> result = [//you query//];
        
        return result;
    }

}

and check it through workbench by using url(/services/apexrest/any name/) in the rest explorer, you will see the JSON response
 
Keith Stephens 18Keith Stephens 18
I don't want to call it from workbench or any other app.  I want the Salesforce class to call the query from the class then pass those results to my rest service.

End result is I have a button on the case page that when clicked with call my SF class run the query pass the results to my rest service to be inserted into sql server.