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
Matt FolgerMatt Folger 

Creating a New Record Button In a VisualForce Page

Hi, I'm creating a new VF page, it queries some records based on user inputs.  Then it searches for those records and displays the results.  It would be really nice if there was a "New" button in this page where if the user couldn't find the item they were looking for they could create it.  I guess it wouldn't technically be a New Record button as much as it would take them to a new record creation screen.  Anyone know how to do this?  I can't find anything.
Best Answer chosen by Matt Folger
Denis VakulishinDenis Vakulishin
Hi,
<apex:outputLink value="{!URLFOR($Action.Account.New)}">Create New Account</apex:outputLink>

(change "Account" to whatever object it is you are dealing with)

All Answers

Denis VakulishinDenis Vakulishin
Hi,
<apex:outputLink value="{!URLFOR($Action.Account.New)}">Create New Account</apex:outputLink>

(change "Account" to whatever object it is you are dealing with)
This was selected as the best answer
Matt FolgerMatt Folger
Man Dennis, you rock.  And so fast.

=^D
Brian StruebingBrian Struebing
This is great Denis, thanks for this solution.  I am currently using this to create a new record on a custom object, however it is the child of an opportunity.  Can I use some expanded URL to relate the records so the user does not have to relate it themselves?

Thanks! 
ashutosh sahoo 10ashutosh sahoo 10
how to create a new button with record type also...?
 
Mokesh RamMokesh Ram
Thanks for the code @Denis Vakullshin