Skip to main content

SharePoint 2013 - Start a Site Workflow using a Custom Action

In recent travels I've encountered what seems to be either a product limitation or a bug. After digging around some it appeared that I wasn't the only one facing this challenge, and unfortunately there wasn't a concrete enough solution or workaround out there. Hence the blog post hoping to save some of you the unnecessary hair-pulling which I had to endure.

My task was fairly simple; "Start a Site Workflow using a Custom Action button". The first part, creating a Custom Action, is trivial. This can be done in Visual Studio or SharePoint Designer. For the sake of simplicity I used SharePoint Designer.

Create a Custom Action button

  1. Start up SharePoint Designer 2013 and connect to the desired site.
  2. From the left navigation select Lists and Libraries.
  3. I'm using a simple list called "List One". Boring name, but easy to follow. :)
  4. Click on the list name to manage list settings.
  5. From the ribbon select Custom Action button then click View Ribbon from the drop-down menu.
  6. NOTE: The "View Ribbon" choice gives us the freedom to specify the section of the ribbon where action button will be placed. Other choices like Display/Edit/New Form Ribbon are used to launch those list form respectively.
  7. Next, a pop-up dialog prompts us to enter some info (i.e., Name, Type of Action, etc.).
  8. NOTE: Unfortunately this is where we run into problems. "Initiate workflow" drop-down menu does not show any of the existing workflow definitions or associations. Also, keep in mind this is the site collection root web, where all of my workflows are defined.

    Very strange. We move along, but we'll come back to this.
  9. In advanced options we specify Button Image URL and location of where the button will appear.
  10. NOTE: Either 16x16 or 32x32 size for the button image will work.

    Notice that in the Ribbon Location I'm placing the button inside the Workflow section of the ribbon.

    Sequence number is optional and it specifies the order of precedence in which the button will appear.
  11. Click OK to save changes
Let's navigate to our list to see how the new Custom Action button renders.
NOTE: Notice our Send E-mail custom action is placed inside the Workflow section of the server ribbon as we specified.

Create a Site Workflow

To ensure we stay focused on the context here, we'll create a workflow to send a simple E-mail. Again, we turn to SharePoint Designer to do this fairly quickly. This is what our Site Workflow looks like in the workflow text-based designer.
Again, we are not aiming for greatness here in terms of workflow complexity, just enough to demonstrate the functionality (or lack thereof) with a Custom Action.

Initiate Workflow via Custom Action

I promised we'd come back to this so here we are. Let's edit the Custom Action we created earlier so we can specify the "Initiate workflow" parameter.
  1. In SharePoint Designer, click on the Custom Action to edit it's settings.
  2. Select "Initiate workflow" radio button and click on the drop-down arrow.
If the Site Workflow actually shows up as an option in the drop-down then save yourself some time and stop reading. You're done! However, I'm confident you will continue reading as the drop-down menu appears empty.

The Workaround

It appears that by design "Initiate workflow" query returns only List Workflows. This means that any Reusable or Site Workflows that you may have defined/published will NOT show up in the drop-down as an option. Although not ideal, there is a workaround.

The trick is to use "Navigate to URL" as the workflow trigger instead. To do this successfully we will need to create an Initiation Form for the Site Workflow. Let's do that quickly.
  1. We open up the "Send E-mail" site workflow from earlier and select Initiation Parameters from the server ribbon.
  2. Association and Initiation Form Parameters dialog opens. Select "Add..." to proceed and choose a type of parameter. I'm simply using a Multi-line Text field called Comments.
  3. NOTE: Initiation Parameters are typically used when trying to collect some data from a user upon them manually starting a workflow. In this case we are using it as a trigger for our Custom Action button.
  4. Click Next to proceed.
  5. Enter a default value if you wish.
  6. Select Finish to create the parameter. If successful, the parameter shows up in the dialog.
  7. Click OK.
  8. Make sure to Save and Publish the workflow if you haven't already.
In the "Forms" section of the workflow information page you will notice a new form is automatically created (WFInitForm.aspx).
Now that the initiation form has been successfully created all that is left for us to do is edit the Custom Action button and populate the "Navigate to URL" parameter with the URL of the Initiation Form.
  1. Edit the Custom Action button using SharePoint Designer.
  2. Scroll down to the "Navigate to URL" section and click the Browse button.
  3. Navigate to the location of the Initiation Form.
  4. NOTE: Initiation forms are all stored inside the wfsvc directory located at the root web of the site collection.

    Each form resides within a folder named by the GUID of the respective workflow. Make sure you're selecting the correct workflow folder.
  5. Click OK, the once again to save changes to the Custom Action.

Let's Test

Let us navigate to the list where we created our Custom Action button and see how this works.
  1. Once there, click on the Items or Files tab from the server ribbon (depending on whether it is list or library), and click the Custom Action.
  2. If we did everything correctly, we should be redirected to the workflow Initiation Form.
  3. We click Start and await for the workflow to execute.
  4. Check your inbox.
Thanks for reading!

Comments

Popular posts from this blog

SharePoint Server Search - Error Starting

Problem I recently ran into this snag at a client site while setting up the Search Service Application.  I was able to create the service application without a problem however when I attempted to start the SharePoint Server Search service (Manage services on server page) I kept getting Error Starting . After taking a peak at the logs I found the following: An attempt to start/stop instance of service SharePoint Server Search on server did not succeed. Re-run the action via UI or command line on the specified server. Additional information is below. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) I double/triple checked the permissions and made sure that my Farm Administrator account was a member of WSS_WPG and WSS_ADMIN_WPG groups, and that those groups had full control permissions to the C:\Windows\Tasks and C:\Windows\Temp folders. Resolution I nearly lost hope when I remembered my old lost friend called STSADM.EXE. Just like in the old da...

SharePoint 2013 - Creating and Applying Composed Looks (PowerShell)

If you are a SharePoint administrator looking to quickly apply some basic branding to a site-collection in your SharePoint 2013 environment then you've come to the right spot. Before we begin I assume you have a basic understanding of what Composed Looks are, and perhaps you spent some time playing around with this concept in SharePoint 2013. If not, then don't worry.  Here is a basic primer: Composed Look is basically a package which contains elements used for controlling the overall look and feel of a SharePoint site.  This includes but not limited to Colors, Fonts, Background Image, CSS files, and Master Page files. Once created, Composed Look can be packaged by using the Design Manager feature, or we can use PowerShell to apply it across one or multiple site collections. NOTE: In this post we will be focusing on creating a composed look from an .spcolor file then using PowerShell to apply the design to a site-site collection of our choice.  We wil...

SharePoint 2013 - Can't access the site externally in Internet Explorer ("Page cannot be displayed")

Synopsis Before we start talking about the problem let's understand the setup here.  We have a SharePoint 2013 intranet site that is also configured for access outside of the corporate network.  Employees use the same URL to visit the site both internally and externally via standard ports (80 and 443). Internal URL: http://sharepoint.domain.com Public URL: https://sharepoint.domain.com The site URL has been added to the Local Intranet zone in Internet Explorer for passing domain credentials. Alternate Access Mappings have been configured in such a way that if a user requests the site over HTTP they are automatically re-directed to HTTPS. Internal URL Zone Public URL for Zone https://sharepoint.domain.com Default https://sharepoint.domain.com http://sharepoint.domain.com Default https://sharepoint.domain.com Web application has been configured to use Kerberos protocol for authenticating incom...