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
balraj singh 33balraj singh 33 

Not able to pass id from visualforce to controller. IT is not redirecting to edit page. i see the id filed has null in the url Please help

MY VISUALFORCE PAGE CONATINS
<apex:pageblocktable value="{!var21}" var="a" ID="B">
                <apex:column >
                <apex:commandlink Value="EDIT" action="{!editaccount}" target="_blank">
                 <apex:param value="{!a.id}" assignTo="{!idvariable}"></apex:param>

                    </apex:commandlink>
                </apex:column>
                 <apex:column value="{!a.name}"/>
             </apex:pageblocktable>

MY CONTROLLER APEX:

 public string idvariable{get;set;}  

 public pagereference editaccount()
    {
        PageReference newPage = new PageReference('/'+idvariable+'/e');

  newPage.setRedirect(true);

  return newPage;
    }
Best Answer chosen by balraj singh 33
Bhargavi TunuguntlaBhargavi Tunuguntla
Please try the below code:

Vf Page:
<apex:pageblocktable value="{!var21}" var="a" ID="B">
            <apex:column >
                <apex:commandlink Value="EDIT" action="{!editaccount}" target="_blank">
                 <apex:param value="{!a.id}" name="accId"></apex:param>
                    </apex:commandlink>
                </apex:column>
        <apex:column value="{!a.name}"/>
            
        </apex:pageBlockTable>

Class:
 
public PageReference editaccount()
    {
         Id accId=ApexPages.currentPage().getParameters().get('accId');
        system.debug(contactId);
        return new PageReference('/'+accId+'/e?retURL=/'+accId);
    }

This perfectly worked for me .

Thanks
Bhargavi.​

All Answers

Bhargavi TunuguntlaBhargavi Tunuguntla
Hi

I got the same issue.And this was resolved when I used rerender attribute in the commandlink . Try rerendering the pageBlockTable.

Hope this Helps.

Thanks.
balraj singh 33balraj singh 33
It is not working. getting the same error  URL No Longer Exists.
URL:https://balraj-singh-dev-ed.my.salesforce.com/null/e .it is not value of id 
 
Bhargavi TunuguntlaBhargavi Tunuguntla
Please try the below code:

Vf Page:
<apex:pageblocktable value="{!var21}" var="a" ID="B">
            <apex:column >
                <apex:commandlink Value="EDIT" action="{!editaccount}" target="_blank">
                 <apex:param value="{!a.id}" name="accId"></apex:param>
                    </apex:commandlink>
                </apex:column>
        <apex:column value="{!a.name}"/>
            
        </apex:pageBlockTable>

Class:
 
public PageReference editaccount()
    {
         Id accId=ApexPages.currentPage().getParameters().get('accId');
        system.debug(contactId);
        return new PageReference('/'+accId+'/e?retURL=/'+accId);
    }

This perfectly worked for me .

Thanks
Bhargavi.​
This was selected as the best answer