+ Start a Discussion
SS KarthickSS Karthick 

Get the query string value in Remote Action Method

Hi folks,
       Can anyone tell me how to get the value of query string in Remote Method?
My code as follows
    global static Contact getContact() {
        String CID=ApexPages.currentPage().getParameters().get('id');
        String ContactId=CID.trim();
        contact c= [SELECT Id, FirstName, LastName,Phone FROM Contact WHERE Id= :ContactId];
        return c;

I get the following error message while running the above code
attempt to de reference a null object

How can I fix this error?

Thanks in advance
Best Answer chosen by SS Karthick
      you can't get the querystring parameter inside the @RemoteAction  method  because remoteaction method is stateless.. But if you want to operate on a specific id then you can pass the       id as a paramter from javascript and later receive this in function parameter.
   For reference you can use this link: