Asked by:
Custom Workflow Action in Sharepoint Designer in VS 2010

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 -
CreateSiteAction.cs
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();
try
{
using (SPSite site = new SPSite(context.CurrentWebUrl))
{
using (SPWeb web = site.OpenWeb())
{
web.Webs.Add(
siteName,
"Trip Report: " + siteName,
string.Empty,
1033,
"STS",
false,
false);
}
}
results["success"] = true;
results["exception"] = string.Empty;
}
catch (Exception e)
{
results = new Hashtable();
results["exception"] = e.ToString();
results["success"] = false;
}
return results;
}
}
}CreateActionDefinition.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<WorkflowActions>
<Action Name="Create Site"
SandboxedFunction="true"
Assembly="$SharePoint.Project.AssemblyFullName$"
ClassName="SPDCustomWorkflowActions.CreateSiteAction"
FunctionName="CreateSite"
AppliesTo="all"
UsesCurrentItem="true"
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" />
</RuleDesigner>
<Parameters>
<Parameter Name="__Context"
Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext,
Microsoft.SharePoint.WorkflowActions"
Direction="In"
DesignerType="Hide" />
<Parameter Name="siteName"
Type="System.String, mscorlib"
Direction="In"
DesignerType="TextBox"
Description="Name of the site to create" />
<Parameter Name="exception"
Type="System.String, mscorlib"
Direction="Out"
DesignerType="ParameterNames"
Description="Exception encountered"/>
</Parameters>
</Action>
</WorkflowActions>
</Elements>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
Aaquil
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 | LinkedInThursday, 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/sergelucaThursday, 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 | LinkedInThursday, 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 NarasimanFriday, June 3, 2011 9:24 AM