none
SharePoint 2010 - Publishing site - Custom action with server-side code RRS feed

  • Question

  • Hi,

    In a publishing site with workflow, we want to add a custom button to "Auto Publish" the current page when the user is a member of the Approvers group without triggering the default workflow.  (In our scenario, we don't want to develop a custom Workflow using SharePoint designer).

    The pseudocode ressemble the "approval process":

    - Validate if the user is a member of the "approvers" group

    - Validate the required fields

    - Publish and approve the item.

    --> If the validation fails, we want the code to return "normally" without raising an Exception (displaying the default "An error occurs" to the end user).

    I already put in place the element.xml file to implement the "CustomAction"...

    To handle the "button click" event, I used the code from a sample found on the web which declares a UserControl (implements IPostBackEventHandler) added to the Ribbon.  Inside the PageLoad, the button is hooked with the server code using the SPRibbonScriptManager class.(http://makarandrkulkarni.blogspot.ca/2010/01/new-one.html).

    In the "RaisePostBack" method, my custom code will fit there like a charm....

    But, there seem to be no way to communicate back to the client.  For example, if I validate the required field, I want to get back to the client and display the missing fields....

    Looking at the "PublishCommandHandler", the class inherits from "SPRibbonCommandHandler"...  Inside, there is a way to communicate back with the client "BuildReturnValue", "Set*Message"...

    However, this handler works with "SPPageStateControl" class... This class declares a fixed-length array of handlers which represents the basic publishing handlers...

    So, is there a simple way to implement the behaviour I'm lookinfg for?  

    Thx

    - Mike

    Wednesday, September 3, 2014 2:24 PM