+ Start a Discussion
Steven HoughtalenSteven Houghtalen 

How to call a page from a button on a detail page

I am new at developing VF pages and something that seems pretty basic, I can't find documentation on how to do it.  

I would like to place a custom button on the detail page of an custom object record.  The button would call a VF page that I create to display and edit some fields in that record.  The documentation indicates that I need to append the query parameter to the page url that specifies the ID of the record.  

If I define the button as a link to this url, it will always refer to the same record.  I want the button to refer to the record of the detial page I am currently viewing. This implies that there must be a way to pass the record ID to the VP but I can't seem to find out how.  Very frustrating.

Can anyone help?  Thanks  

David OvellaDavid Ovella
Hello Steven

As I understand, you want a button that takes you to a "visualforce page" where you can edit the record created with the information that has the record
You can try this

1 Created a apex class
public with sharing class YourObjectNameController {

    private final YourObecjtName__c objectname {get; set;}

    public YourObjectNameController(ApexPages.StandardController controller) {
        this.objectname=[Select Id, Name, yourcustomfield__c From YourObjectName__c Where Id= :controller.getId()];

2 Create the visualforce page,
<apex:page standardController="YourObjectName__c" extensions="YourObjectController" tabStyle="OT__c">

  <apex:sectionHeader title="Creación de" subtitle="OT"/>
    <apex:form >
        <apex:messages />
     <apex:pageBlock mode="edit" >  
      <apex:pageBlockSection title="Information" columns="2">
        <apex:inputField value="{!YourObjectName__c.yourcustomfield__c}"/>

3 create the button and in the part of

Display Type: Button
Content Source: Visualforce Page
           Content: YourVFName
Deepthi BDeepthi B
Hello Steven

Please refer to the below for the solution: