[SalesForce] Accessing an object’s actions on a Visualforce page

I have a custom object, Site, with an action that creates a new child record, Holiday, for a Site. I have a Visualforce page that uses the Site standard controller to display a limited subset of Site fields. I'd like to make use of that action in the Visualforce page. Is there a way to surface an object's actions in a Visualforce page? I tried the following,

<apex:commandButton action="{!New_Holiday}" value="New Holiday" id="theButton"/>

but I'm getting an "unknown method…" error which makes me think I'd need to make a controller extension (and code for the action). I can created the extension if that's how I need to do this, but I'm hoping to find a way to use an existing action.

I've found plenty of info about using visualforce pages as actions, but nothing yet about surfacing actions in VF pages.

Note: I'm mainly intending this for use in Salesforce1, but it won't bother me if this action is available in regular Salesforce and Salesforce1.

Edited to add
The following code works:

<apex:commandButton action="{!URLFOR($Action.SiteProgram__c.New_Holidaybtn)}" value="Create New Holiday" id="whatevs"></apex:commandButton>

It appears that object-specific actions are not accessible via $Action, but buttons and links are.

Best Answer

The new action doesn't appear in the list of Standard Controller Actions but you should be able to use a global action like:
<apex:outputLink value="{!URLFOR($Action.Holiday__c.New)}">Create New Holiday</apex:outputLink>

You could also create an object specific action on Site by following these steps from the Publishers Action Implementation Guide:

To create object-specific actions:
1. From Setup, click Customize, choose the object for which you want to create an action, and click Buttons, Links, and Actions.
2. Click New Action.
3. Select the type of action you want to create.
4. Customize the action:
• For a Create a Record action, select the type of object to create.
◊ If there’s more than one record type for that object, select the one you want to use for records created through this action.
◊ If there’s more than one relationship between the object on which you’re creating the action and the target object, select the field you want to populate automatically when a record is created. (For objects with only one relationship, the Relationship Field is set by default.)

Related Topic