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
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Pass record id on click of commandlink

Hi Everyone ,
         I have a requirement with me and I need some help. Please find the details of the requirement given below.

1. I have a vf search page that searched on opportunity records and returns results. On opportunity name column of result section I want user to click , upon user click in tyhe bottom half of the search page , another vf page (inline) should open up . I have the code given below. Just need help with passing the reocrd id parameter from command link to detail page and it's controller.


 Search Page code:


    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!Opportunities}" var="opp">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Opportunity Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                // This section represents column of serach results.
                <apex:commandlink value="{!opp.Name}" rerender="RecordDetailSection" action="{!ClearOrder}">
                    <apex:param name="abc" value="{!opp.id}"/>
                </apex:commandlink>
                

        </apex:pageBlockTable>    
 </apex:pageBlock>

// This section is inline details page of click opportunity
      
  <apex:pageBlock id="RecordDetailSection" rendered="{!RenderDetail}">
     <apex:include pageName="SiteDetailPage"/>
  </apex:pageBlock>

</apex:page>



Site detail Page controller:


public class CurrentRecordIdDemoController{
public String currentRecordId {get;set;}
public String parameterValue {get;set;}
public Opportunity Opp{get;set;}
public Integer DocSize{get;set;}




    public CurrentRecordIdDemoController() {
        //currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
        Id currentRecordId = System.currentPageReference().getParameters().get('abc');
        Opp = [select  Awarded_Project__c,(Select Doc_Name__c,Link__c,Type__c,CreatedDate from Documents__r Order By CreatedDate desc) from Opportunity where id =: currentRecordId ];
        parameterValue = ApexPages.CurrentPage().getparameters().get('nameParam');
        DocSize=Opp.Documents__r.size();
        
    }

}
Alejandro Gonzalez 18Alejandro Gonzalez 18
When creating the Parameter link, add the variables you need and assign it to a variable that exists on the controller

VisualForce Page. Notice the "assingTo:
<apex:commandLink action="{!ApproveUser}" value="Approve">
						<apex:param name="userId" value="{!item.Id}" assignTo="{!userId}" />
					</apex:commandLink>
Controller
public string userId{
    	get;set;
    }
 public PageReference ApproveUser()
    {
        
        Id val = Id.ValueOf(userId); 
// use the ID as you wish 
...
...
}