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
ThomasmThomasm 

Visualforce related list new button

I created a visualforce related list on the account to make it easier to find records but need to add a new button to the list.  I need the button to open a new tab and create a record for that related list.  I am not sure where to go but here is what i have

VF Page
<apex:page standardcontroller="Account" extensions="AccountRelatedPages">
<style> .fewerMore { Display: none;} </style>
 <apex:form >
<apex:pageblock id="Safety_Forms" title="Safety Forms">
<apex:commandButton value="New" />
<apex:pageblocktable value="{!AF}" var="a" rendered="{!not(isNull(emp))}">
<apex:column >
<apex:outputlink target="_Blank" value="/{!a.id}">{!a.name}</apex:outputlink>
/apex:column> </apex:pageBlocktable>
</apex:pageblock>
</apex:form>
</apex:page>

Class
public class AccountRelatedPages {

Private list<account_form__C>Af;

Private Account Act;
    Public AccountRelatedPages(ApexPages.StandardController Controller){this.Act=(account)controller.getRecord();} 
 public list<account_form__C>getAF()
 {
 AF=[Select id, Name from account_form__C WHERE account__C=:act.id and RecordTypeId in (SELECT Id FROM RecordType WHERE Name = 'Incident Investigation')];
 return af;
 }

}
pconpcon
Have you tried
 
<apex:commandButton action="{!new}" value="New" />

NOTE: When including code please use the "Add a code sample" button (icon <>) to increase readability and make referencing code easier.