---
schema_version: "1"
id: bab9a4473d02c5d0c5b5b6f71c7e5cf982152a4248fcdc72b5c44dab46e4ab0d
title: Visualforce Pages as Global Custom Actions
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/custom_actions_vf_pages_for_global_actions.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.custom_actions_vf_pages_for_global_actions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d977ffe17895e7fd96de7d100a277e9b9d3f8d534b270b406972532222ec9c27
description: Visualforce pages used as global actions can be invoked in many different places and don’t have a specific record associated with them. They have complete freedom of action, which means it’s up to you to write the code.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Visualforce Pages as Global Custom Actions

Visualforce pages used as global actions can be invoked in many different places and don’t have a specific record associated with them. They have complete freedom of action, which means it’s up to you to write the code.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col style="width:100%"></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Group</strong>, <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, <strong>Contact Manager</strong>, <strong>Database.com</strong>, and <strong>Developer</strong> Editions</td></tr></tbody></table>

Visualforce pages you create to use as global actions can’t use a standard object controller. You must write a custom controller to handle the page.

When a global action completes, the user is either redirected to a parent record created as part of the action or returned to where they started.

This code sample shows a Visualforce page designed to be used as a custom action on any object that supports actions. This action lets users create cases from record detail pages, Chatter, Chatter groups (except customer groups), or the home page. It has a different user interface from standard create actions. As with all global actions, the records created through this action aren’t associated with other records.

```markup
<!-- Custom controller -->
public with sharing class CreateCaseController {
    public Case theCase {get; set;}
    public String lastError {get; set;}
    public CreateCaseController() {
        theCase = new Case();
        lastError = '';
    }
      
    public PageReference createCase() {
        createNewCase();
        theCase = new Case();
        return null;
    }
       
     private void createNewCase() {      
        try {
            insert theCase;
            
            FeedItem post = new FeedItem();
            post.ParentId = ApexPages.currentPage().getParameters().get('id');
            post.Body = 'created a case';
            post.type = 'LinkPost'; 
            post.LinkUrl = '/' + theCase.id;
            post.Title = theCase.Subject;
            insert post;
        } catch(System.Exception ex){
           lastError = ex.getMessage();
        }
    }   
}

<apex:page controller="CreateCaseController" showHeader="false">
    <script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>
    <style>
        .requiredInput .requiredBlock, .requiredBlock {background-color: white;}
        .custompubblock div {display: inline-block;}
        .custompublabel {width:54px;}
    </style>
   
     <script>
      function refreshFeed() {
          Sfdc.canvas.publisher.publish({name : 'publisher.refresh',  payload : {feed: true}});
      }
     </script>
   
    
    <div>
        <apex:form >
            <apex:actionFunction action="{!createCase}" name="createCase" rerender="out" oncomplete="refreshFeed();"/> 
            <apex:outputPanel id="out" >
                <div class="custompubblock">
                    <div>Subject:&nbsp;</div><apex:inputField value="{!theCase.subject}" style="width:500px;" />
                </div>
                <div class="custompubblock">
                    <div class="custompublabel">Account:</div><apex:inputField value="{!theCase.accountId}" 
                    style="margin-left:0;"/>&nbsp;&nbsp;&nbsp;
                    <div>Contact:&nbsp;</div><apex:inputField value="{!theCase.contactId}" />
                </div>
                <apex:inputField value="{!theCase.description}" style="width:500px;height:92px;margin-top:4px;" />
                <div class="custompubblock" style="margin-top:5px;">
                    <div>Status:&nbsp;</div><apex:inputField value="{!theCase.status}" />&nbsp;&nbsp;&nbsp;
                    <div>Priority:&nbsp;</div><apex:inputField value="{!theCase.priority}" />&nbsp;&nbsp;&nbsp;
                    <div>Case Origin:&nbsp;</div><apex:inputField value="{!theCase.origin}" />
               </div>
                <div style="color:red;">{!lastError}</div>
            </apex:outputPanel>
        </apex:form><br/>
        <button type="button" onclick="createCase();" style="position:fixed;bottom:0px;right:0px;padding:5px 10px; 
        font-size:13px; font-weight:bold; line-height: 
        18px;background-color:#0271BF;background-image:-moz-linear-gradient(#2DADDC, #0271BF);background-repeat:repeat-x;
        border-color:#096EB3;" id="addcasebutton">Create Case</button>
    </div>            
</apex:page>
```

## Requirements for Refreshing Host Pages

To have an object-specific or global custom action refresh the feed on the page that hosts it, the Visualforce page you create to use as that action must:

- Reference the publisher JavaScript file: `<script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>`. (Creating custom Visualforce actions doesn’t require the Canvas SDK.)
- Include this JavaScript call: `Sfdc.canvas.publisher.publish({name : 'publisher.refresh', payload : {feed:true}});`.

#### See Also

- [Visualforce Pages as Object-Specific Custom Actions](https://help.salesforce.com/s/articleView?id=platform.custom_actions_vf_pages_for_object_actions.htm&release=264.0.0&type=5 "A Visualforce page added as a custom action on an object is invoked in the context of a record of that object type. The custom action is passed a specific record ID—the record the user was looking at when the user clicked the custom action. Design the page to act on that specific record type.")
- [Create Global Quick Actions](https://help.salesforce.com/s/articleView?id=platform.creating_global_actions.htm&release=264.0.0&type=5 "You can add global actions to any page that supports actions, like the Home page, the Chatter tab, object pages, and custom Lightning app pages. For example, add a Log a Call action to global layouts so users can record call details right from a Chatter thread.")
- [Quick Actions](https://help.salesforce.com/s/articleView?id=platform.actions_overview.htm&release=264.0.0&type=5 "Quick actions enable users to do more in Salesforce and in the Salesforce mobile app. With custom quick actions, you can make your users’ navigation and workflow as smooth as possible by giving them convenient access to information that’s most important. For example, you can let users create or update records and log calls directly in their Chatter feed or from their mobile device.")