+ Start a Discussion
Eric Anderson 54Eric Anderson 54 

Cannot add visualforce page call button to child list

Hi there,

We have an App that is a 'Investigation' Custom object. Within that custom object, I have one or more witnesses as 'Child custom' objects. Because the 'Save' in the default entry form (Salesforce out of the box) for the child object does not take us back to the 'Parent custom object' the way the user wants it too, we used a 'URL Hack'. We got chastised for this and told we should use a VisualForce page. I'm fairly green when it comes to VisualForce development, so I could use all of the help that I can get. In a 'Master-Detail' related lists, I'm trying to create a data entry form using VisualForce. I've entered most of the mark up in the VF page and my code looks like the following:
<apex:page standardController="Witness__c">
<apex:form id="Witness_Entry_Form">
    <apex:pageBlock title="Create Witness">

    <apex:pageBlockSection columns="1">  
    <apex:inputField value="{!Witness__c.Name}"/>      
    <apex:inputField value="{!Witness__c.CDC_Number__c}"/>
    <apex:inputField value="{!Witness__c.CDC_Offender__c}"/>
    <apex:inputField value="{!Witness__c.Eye_Color__c}"/>
    <apex:inputField value="{!Witness__c.First_Name__c}"/>
    <apex:inputField value="{!Witness__c.Hair_Color__c}"/>
    <apex:inputField value="{!Witness__c.Last_Name__c}"/>
    <apex:inputField value="{!Witness__c.Request_Witness__c}"/>

    <apex:pageBlockButtons >
      <apex:commandButton action="{!save}" value="Save"/>


However, when I try to create a button within the Witness object with a display type of 'List button', and then select 'VisualForce' for the Content source, my VisualForce page is not listed in the 'Content' drop down box and as a result I get a 'You must enter a value' error.

I would sincerely appreicate any help I can get in regards to this.


Alain CabonAlain Cabon
Hello Eric,

 'List button', and then select 'VisualForce' : need a standard list controller with the attribute recordSet=  on the <apex:page> component.


Your VFP doesn't contain a list (with a loop <apex:repeat> or <apex:datatable>).

You can use a Detail Page Link  or a Detail Page Button instead (not a List Button

Eric Anderson 54Eric Anderson 54
Hi there Alain,

Thank you for your response. I understand what you are saying, but in my situation, it doesn't help me. Maybe I didn't explain what I am trying to do well enough, so let me get some more detail.

I have a Parent custom object called 'Investigations'. Within 'Investigations', I have a custom child object called 'Witness'. We have Witness set up as a 'Master-detail' relationship to Investigations. We have a 'Related list' of 'Witnesses' displayed within the 'Investigations' parent object. If we use the default 'New' button for the 'Witness' entry, when you click on the 'Save' button after entering the Witness information, you are not taken back to the parent record as the Customer has required. So, we resolved this issue with a 'URL Hack'. However we have been told that URL hacks are not supported and should be avoided. So, we have created this 'Visualforce' page to serve as a replacement for the default Child object data entry screen that is spawned out of the default 'New' button for the child object.

So the question is, how do I launch my custom 'Visualforce' application so that I can input Witness information? If I use the 'Witness__c' as the standard controller in the VF code, I can not pull up the 'Witness' VF application when trying to build a button at the parent object level. If I build the launch button at the Child level, though I can select the VF application when building the button, I can't seem to find the 'Button' in any of the layout editors so that I can place it in relationship to the Witness Related list.

Any additional help would be greatly appreciated.

Thanks! - Eric-
Alain CabonAlain Cabon

You should use a quick action with Predefined Field Values.


Alain CabonAlain Cabon
You could also try a button link URL with : /apex/myVFPname?param1=...)

Constructing Effective Custom URL Buttons and Links​


You will become a pro of the URL buttons and Links with this article.