1

I have below static method where I am trying to add an Id to a set of Ids. This throws subject line error.

Can someone please let me know where i am doing wrong?

Apex Method

public Id currentRecordId {get;set;}

public static Set<Id> childrenIds {
 get{
  if( childrenIds == null ) childrenIds = new Set<Id> { };
        return childrenIds ;
 }
 set;}

 @RemoteAction
    public static List<Account_Plan__c > contactListRemoting (String searchTerm) {
        List<Account_Plan__c > AccountPlansList = new List<Account_Plan__c>();
      childrenIds.add(ApexPages.CurrentPage().getparameters().get('Id')); // Error throws here.
             fetchChildrenByLevelTest(childrenIds);

      AccountPlansList = Database.query('....');

        return AccountPlansList ;
    }
0

1 Answer 1

3

ApexPages.currentPage() only works for non-static Visualforce methods. You cannot get page parameters in a RemoteAction method.

Instead, pass the recordId in from the page:

@RemoteAction
public static List<Account_Plan__c > contactListRemoting (String searchTerm, Id recordId) {

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .