• mitch_miller
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies
mitch_miller
This pattern for the controller seems to work for others but I am unable to access any variables in the controller to pass thequery as an arguement - I assume because it is static:

global with sharing class Participant_Surgeries_controller {


public String [] participants{get;set;}
private final Participant__c participant;

global Static String lastName;

  ApexPages.StandardController m_controller;

    public Participant_Surgeries_controller(ApexPages.StandardController controller) {
    m_controller = controller;
    this.participant = (Participant__c) controller.getRecord();
}
@RemoteAction
global static List<Surgery__c> getSurgeries(){
  List<Surgery__c> surgeries = new List<Surgery__c>();
  
  try{
    surgeries = [Select  Name,  Surgery__c.Scheduled_Date__c  from Surgery__c
               Where Surgeon__r.Last_Name__c = :this.participant.Last_Name__c ]; //variations with 'this.participant' or local variable are not in scope 
                                                                                                                                                  // but a hard coded value works fine.

    } catch(DMLException e){
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Error creating new page.'));
            return null;
    }
       return surgeries;
}
}
mitch_miller
This pattern for the controller seems to work for others but I am unable to access any variables in the controller to pass thequery as an arguement - I assume because it is static:

global with sharing class Participant_Surgeries_controller {


public String [] participants{get;set;}
private final Participant__c participant;

global Static String lastName;

  ApexPages.StandardController m_controller;

    public Participant_Surgeries_controller(ApexPages.StandardController controller) {
    m_controller = controller;
    this.participant = (Participant__c) controller.getRecord();
}
@RemoteAction
global static List<Surgery__c> getSurgeries(){
  List<Surgery__c> surgeries = new List<Surgery__c>();
  
  try{
    surgeries = [Select  Name,  Surgery__c.Scheduled_Date__c  from Surgery__c
               Where Surgeon__r.Last_Name__c = :this.participant.Last_Name__c ]; //variations with 'this.participant' or local variable are not in scope 
                                                                                                                                                  // but a hard coded value works fine.

    } catch(DMLException e){
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'Error creating new page.'));
            return null;
    }
       return surgeries;
}
}
My Controller Code:
global with sharing class CustomHighlightsPanelController {

    public Account accountInstance;
    global static String accountName {get; set;}
    global static String primeTabValue {get; set;}

    public CustomHighlightsPanelController(ApexPages.StandardController controller) {
        accountInstance = (Account)controller.getRecord();
        accountName = accountInstance.Id;
        System.debug('_______##############______'+accountName);
    }
    public PageReference FetchTabId() {
        return null;
    }
   
    @RemoteAction
    global static Premium_Payment__c[] loadPremiumPaidRecs() {
        List<Premium_Payment__c> premiumPaymentList = new List<Premium_Payment__c>();
        premiumPaymentList = [SELECT Id, Customer_Name__c, Paid_Premium__c, Policy__c, Premium_Paid_Date__c,Premium_Paid_Month_Year__c
                                FROM Premium_Payment__c WHERE Customer_Name__c =: accountName];
        return premiumPaymentList;
       
    }

}


accountName inside the SOQL query is getting null. but the variable accountName in the system.debug line gives a value.
How can i pass the contructor variable to the global static method which is defined as @RemoteAction.
  • March 18, 2014
  • Like
  • 1