Background I'm working with two VF pages, OutOfOffice and AddNewOutOfOffice. The OutOfOffice page displays a list of custom object records. For each record there is an edit and a delete button. There is also a single 'add new' button at the top the OutOfOffice that links to the AddNewOutOfOffice page.

Issue I need the edit button(s) on the OutOfOffice to link to the AddNewOutOfOffice page and pass the record ID into the URL. However with my current code, when I click the edit button I get the url /AddNewOutOfOffice?id=null

Here's what I have so far for the edit button in the VF Page:

<apex:repeat value="{!OOOrecs}" var="OOO">
                <apex:commandButton value="Edit" action="{!EditOutOfOffice}"/>
                    <apex:param name="oooIdEdit" value="{!OOO.id}" assignTo="{!oooIdEdit}"/>
                <apex:commandButton value="Delete" action="{!deleteOOO}" rerender="all">
                    <apex:param name="oooIdDelete" value="{!OOO.id}" assignTo="{!oooIdDelete}"/>

and controller:

    public String oooIdEdit {get;set;}

    public PageReference EditOutOfOffice() {
    return new PageReference('/AddNewOutOfOffice/?id='+oooIdEdit);

This is a known issue,use rerender with commandbutton to fix this (or) use command link and style it to make it look like a command button :


Why does apex:param assignTo work with apex:commandLink but not apex:commandButton?

  • Updated to <apex:commandButton value="Edit" action="{!EditOutOfOffice}" rerender="all"/> but am still having the same issue. Did I use rerender wrong or is their another workaround for command button?
    – John_Henry
    Jul 31 '15 at 17:58
  • 1
    @John_Yankee apex:param must be enclosed within apex:commandButton - you have it as a peer (sibling)
    – cropredy
    Jul 31 '15 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.