Custom Workflow Action in Sharepoint Designer in VS 2010 RRS feed

  • Question

  • Hi,

    I have been trying to create a custom workflow activity using Sandboxed solutiuon for new site, here is the code which I found on microsoft blog. It creates the Custom workflow activity properly and I could use the Action in my Workflow correctly & publish the workflow but when I execute the workflow, I get a message in Sharepoint list as Error occured in my workflow column. I tried to log the exception message but it seems that there is no exception message sent out from my custom activity VS solution. Below is the code which is implemented in the VS solution -


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using System.Collections;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.UserCode;

    namespace SPCreateSiteWorkflowAction
        public class CreateSiteAction
            public Hashtable CreateSite(SPUserCodeWorkflowContext context, string siteName)
                Hashtable results = new Hashtable();
                    using (SPSite site = new SPSite(context.CurrentWebUrl))
                        using (SPWeb web = site.OpenWeb())
                                "Trip Report: " + siteName,

                    results["success"] = true;
                    results["exception"] = string.Empty;
                catch (Exception e)
                    results = new Hashtable();
                    results["exception"] = e.ToString();
                    results["success"] = false;

                return results;





    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">


        <Action Name="Create Site"
        Category="Sandboxed Workflow Actions">

          <RuleDesigner Sentence="Create Site with name %1 (exceptions logged to %2)">
            <FieldBind Field="siteName" Text="Site Name" Id="1"
                DesignerType="TextBox" />
            <FieldBind Field="exception" Text="Exception" Id="2"
                DesignerType="ParameterNames" />

            <Parameter Name="__Context"
                  DesignerType="Hide" />
            <Parameter Name="siteName"
                  Type="System.String, mscorlib"
                  Description="Name of the site to create" />
            <Parameter Name="exception"
                  Type="System.String, mscorlib"
                  Description="Exception encountered"/>





    Note: We did set the feature scope to Site in Feature1.feature properties.

    Please do let us know if you find anything missing inabove code or anything needs to be done in addition to this.

    Thanks in advance


    Wednesday, June 1, 2011 9:33 AM

All replies

  • You activity is failing because these lines are incorrect: (the columns you are referring to do not exist)

         results["success"] = true;

         results["exception"] = string.Empty;

    They should be:


      results["Status"] = "Success";

      results["Except"] = string.Empty;


    You will need to correct the exception handler code block aswell.

    Also see: http://msdn.microsoft.com/en-us/library/ff798499.aspx (Step 5)

    Simon Rennocks | LinkedIn
    Thursday, June 2, 2011 1:27 AM
  • Thanks Simon i tried but no luck so far, getting same error


    Thursday, June 2, 2011 6:57 AM
  • Why don't you debug the custom activity to figure that out ?
    Serge Luca; MVP blog: http://sergeluca.spaces.live.com Devoteam Belgium. http://twitter.com/sergeluca
    Thursday, June 2, 2011 10:23 AM
  • Hi,

    Here is the steps i am following to create & deploy custom WF activity.

    1-     VS project on Sandbox solution

    2-     Added class (CreateSiteAction.cs)

    3-      Empty Element (CreateActionDefinition.xml)

    4-      package solution

    5-     Added .wsp file to my SharePoint site solution and activated

    6-     Open site in SharePoint Designer 2010

    7-     Created Workflow with new custom activity

    8-Published workflow

    9- Create new item list & start WF.

    When WF starts it shows error message "error occurred without any log or exception", Please let me know if this can be debug & do send me steps to debug.


    Thursday, June 2, 2011 12:21 PM
  • To debug a sandboxed solution you have to attach to Process to the SPUCWorkerProcess.exe assembly. Also I would check the ULS logs and the Event viewer if you have not already checked these.

    Simon Rennocks | LinkedIn
    Thursday, June 2, 2011 12:29 PM
  • In this case you may not be able to do an interactive debugging by attaching SPUCWorkerProcess.exe. The recommended way is that you can add Trace Statements to your code-behind (to your workflow activity) and run the DebugView.exe tool on the server. This would help you to trace code execution and diagonize errors
    Sundar Narasiman
    Friday, June 3, 2011 9:24 AM