Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do I make a custom publish botton for a page and make it do the same as the ribbon publish botton? 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
add comment

2 Answers

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
add comment

@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]);
    }
</script>
<input type="button" onclick="javascript:Custom_Submit('PageStateGroupPublish'); return false;" value="Publish" id="btnPublish"></input>
share|improve this answer
add comment

Your Answer

 
discard

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.