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
GuyClairboisGuyClairbois 

Recreate standard 'New' button on Visualforce page

I am creating a VF page on a standard controller. I'd like to create a button on the page that opens the new Record input screen (similar to the one on any tab home page). However, I can't find the correct action syntax for my commandButton.

 

Is this feature actually available for VF?

 

Many thanks,

Guy

Best Answer chosen by Admin (Salesforce Developers) 
Jon Mountjoy_Jon Mountjoy_

I think there's a much better way:

 

<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

thangasan@yahoothangasan@yahoo

Hai

 

  This is one way , I am not sure correct way

//page
<apex:commandButton action="{!new}" value="New"/>

 

// Controller

public PageReference new() {
    // Give ur Object Id Instead 'a0Z', you can see this value in bottom of browser when cursor moves to your Object tab .
    PageReference page = new  PageReference('/a0Z/e');
    page.setRedirect(true);
    return page;
}

Regards
Thanga

Jon Mountjoy_Jon Mountjoy_

I think there's a much better way:

 

<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
SCRSCR

You should be able to invoke any of the Standard Buttons that are available with a Standard Controller using VS markup similar to this:

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

 

You can also specify a VS page to Override a standard Tab or to Override a Standard Button in Setup for the target object.  Would need a bit more detail (VS code and any controller extension code you have created, plus a description of expected behavior) to better understand the desired functionality you seek.
GuyClairboisGuyClairbois

Jon, your solution works perfectly.

 

SCR, there is no such option for the "New" screen. (like e.g. {!New})

Message Edited by GuyClairbois on 07-29-2009 06:58 AM
kprkpr

Is there any way to know all the actions associated with an sObject?

 

I ask this because the Actions are not very intuitive.

 

How can I say that the 'Edit All'  button on the OpportunityProduct related list has the following action?

$Action.OpportunityLineitem.EditAllProduct

 

I would appreciate if anyone could point me to some sort of documentation for this.

 

Thanks

Art C.ax1621Art C.ax1621

If you would like a New button instead of a URL link, you can use following markup.  Replace MY_CUSTOM_OBJECT__C with name of a standard or custom object type defined in your org.

 

<div style='text-align:center;padding-bottom:3px;'>
<form action="{!URLFOR($Action.MY_CUSTOM_OBJECT__C.New)}" method="get" target="_parent">
<input type="hidden" name="retURL" value="{!$CurrentPage.URL}"/>
<input type="submit" value="New"/>
</form>
</div>