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
Abhishek Sharma 527Abhishek Sharma 527 

passing Date to Backend

Hello Experts, I have Apex class where I'm running query under a method and this goes to JS page but I don't know how to pass the data back to Apex.
@AuraEnabled  //dynamic filter
    public static List<queryWrap> DynamicFilter(String startDate, String endDate, String Provider){

        String status1 = 'Non-Billable';
        
        String evtQuery = 'Select Id, Start_Date_Time__c, EndDateTimeV3__c, Additional_Provider_Name__c, Subject from Event where Appointment_status__c = :status1';
        
        if(!String.isBlank(startDate)){
            Datetime stDate = date.parse(startDate);
            evtQuery = evtQuery + ' AND Start_Date_Time__c =: startDate';
        }
        
        if(!String.isBlank(endDate)){
            Datetime enDate = date.parse(endDate);
            evtQuery = evtQuery + ' AND EndDateTimeV3__c =: endDate';
        }

        if(!String.isBlank(Provider)){
            evtQuery = evtQuery + ' AND Additional_Provider_Name__c =:Provider';
        }

 Please Suggest !
Best Answer chosen by Abhishek Sharma 527
SubratSubrat (Salesforce Developers) 
Hello Abhishek ,

To pass data from a JS page back to Apex, you can use a server-side action method in your Apex class and call that method from your JS controller using an Apex method in the lightning framework.

Please review this documentation for your ask -> https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm


Hope it helps !
Thank you.