+ Start a Discussion

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}"/>
                // This section represents column of serach results.
                <apex:commandlink value="{!opp.Name}" rerender="RecordDetailSection" action="{!ClearOrder}">
                    <apex:param name="abc" value="{!opp.id}"/>


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


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');

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}" />
public string userId{
 public PageReference ApproveUser()
        Id val = Id.ValueOf(userId); 
// use the ID as you wish