SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I make a custom publish button for a page and make it do the same as the ribbon publish button? We have a request from the customer to make a simple page that should have a custom publish button in addition to the publish button in the Ribbon (see picture). I have searched google and tried, but could not find any solution to this.

A possible solution could involve the SPContext.Current.File.Publish("myComment"); but this demands a lot of custom handling if there is a workflow?

Publishing button

share|improve this question
ExecuteOrDelayUntilScriptLoaded(function () {
        var pageStateGroupPublishValue = SP.Ribbon.PageState.PageStateCommands.pageStateGroupSubmitForApproval;
        SP.Ribbon.PageManager.get_instance().executeRootCommand(pageStateGroupPublishValue, window.g_CUIcommandProperties, { CommandId: pageStateGroupPublishValue }, null);
    }, "sp.ribbon.js");
share|improve this answer

@Andrey Markeev, Looks like window.g_CUIcommandProperties is undefined on some pages. This code worked for me:

<script type="text/javascript">
    function Custom_Submit(command)
        SP.Ribbon.PageState.Handlers.showStateChangeDialog(command, SP.Ribbon.PageState.ImportedNativeData.CommandHandlers[command]);
<input type="button" onclick="javascript:Custom_Submit('PageStateGroupPublish'); return false;" value="Publish" id="btnPublish"></input>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.