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
MandadiMandadi 

How to get the record or recordId from vf page to Apex class or extension?

Hi All,

 

    I have displayed list of records in vf page.For each record i have a custom button.

      Now Whenever i click that button, i want to get that particular record into apex class.

 

Can anyone tell me how we can get the particular record from vf page to apex class.

 

 

Thanks in Advance...

hitesh90hitesh90

Hi Mandadi,

 

Try to use <apex:parm> tag of visualforce to pass the record or recordId from vf page to Apex class or extension.

see below example for that.

 

Visualforce Page:

<apex:page controller="param" >
    <apex:form>
        <apex:commandButton value="Proceed to Upload" action="{!proceedioUpload}" id="uploadButton">       
           <apex:param value="org" name="uploadType" assignTo="{!uploadType}" id="param"/>
        </apex:commandButton>
    </apex:form> 
</apex:page>

 

Apex Class:

public class param{
    public String uploadType {get; set;} 
    public pageReference proceedioUpload(){ 
        system.debug(uploadType); 
        system.debug(ApexPages.currentPage().getParameters().get('uploadType')); 
        return null; 
    }
}

 

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/