|
|
|
Started: 28/04/2009 09:30 | |
|  | Workflow Out Parameter not working in SPD Hey everyone.
I have created a custom action in Visual Studio 2008 to create a discussion list item based on a list item.
I want to output the URL to the discussion item from the Workflow to a variable, so that i can update a link column in the original List Item to point to that new discussion.
When I try to configure the activity in SPD I get prompted to create a variable of type List Item ID. Since my properties are just Int32, how is it deciding that this is a List Item ID, rather than a straight int? Also, after creating this list item variable, I am unable to set that value to a number field in my original list. I just get stars around the text that references that parameter with the message it references paramters that don't exist.
Also, when I tried passing this back as a string (from the int, or when I tried passing a hyperlink back)
Here is the code in my activity class:
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WorkflowActions;
namespace MyCo.Workflow.Actions
{
public partial class CreateDiscussionItemActivity : Activity
{
#region DependencyProperties for the Activity
public static DependencyProperty ListIdProperty = DependencyProperty.Register("ListId", typeof(String), typeof(CreateDiscussionItemActivity));
public static DependencyProperty ToListIdProperty = DependencyProperty.Register("ToListId", typeof(String), typeof(CreateDiscussionItemActivity));
public static DependencyProperty ListItemProperty = DependencyProperty.Register("ListItem", typeof(Int32), typeof(CreateDiscussionItemActivity));
public static DependencyProperty DiscussionItemProperty = DependencyProperty.Register("DiscussionItem", typeof(Int32), typeof(CreateDiscussionItemActivity));
public static DependencyProperty DiscussionLinkProperty = DependencyProperty.Register("DiscussionLink", typeof(String), typeof(CreateDiscussionItemActivity));
public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(CreateDiscussionItemActivity));
#endregion
#region Properties
[ Description("The List ID of the list item that we are going to copy to the discussion list (a string representation of the GUID)")]
[ Category("MyCo Workflow Actions")]
[ ValidationOption(ValidationOption.Required)]
[ Browsable(true)]
[ DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public String ListId
{
get { return (String)base.GetValue(ListIdProperty); }
set { base.SetValue(ListIdProperty, value); }
}
[ Description("The Discussion list ID (a string representation of the Guid)")]
[ Category("MyCo Workflow Actions")]
[ ValidationOption(ValidationOption.Required)]
[ Browsable(true)]
[ DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public String ToListId
{
get { return (String)base.GetValue(ToListIdProperty); }
set { base.SetValue(ToListIdProperty, value); }
}
[ Description("The List Item Id ")]
[ Category("MyCo Workflow Actions")]
[ ValidationOption(ValidationOption.Required)]
[ Browsable(true)]
[ DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Int32 ListItem
{
get { return ((Int32)(base.GetValue(ListItemProperty))); }
set { base.SetValue(ListIdProperty, value); }
}
[ Description("The Discussion Item Id ")]
[ Category("MyCo Workflow Actions")]
[ ValidationOption(ValidationOption.Required)]
[ Browsable(true)]
[ DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Int32 DiscussionItem
{
get { return ((Int32)(base.GetValue(DiscussionItemProperty))); }
set { base.SetValue(DiscussionItemProperty, value); }
}
[ Description("The Workflow context, to give access to the current SPWeb")]
[ Category("MyCo Workflow Actions")]
[ ValidationOption(ValidationOption.Required)]
[ Browsable(true)]
[ DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public WorkflowContext __Context
{
get { return (WorkflowContext)base.GetValue(__ContextProperty); }
set { base.SetValue(__ContextProperty, value); }
}
#endregion
#region Constructor
public CreateDiscussionItemActivity()
{
InitializeComponent();
}
#endregion
#region Overidden Methods
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
// Get the list
SPList sourceList = __Context.Web.Lists[new Guid(ListId)];
// Get the list item
SPListItem item = __Context.GetListItem(sourceList, ListItem);
// Get the discussion list
SPList targetList = __Context.Web.Lists[new Guid(ToListId)];
// Create the discussion item
SPListItem discussionItem = SPUtility.CreateNewDiscussion(targetList.Items, item.Title);
#region create discussion Body
StringBuilder DiscussionBody = new StringBuilder();
DiscussionBody.Append( "<p>A new Infrastructure request has ben created and approved into the GTC</p>");
DiscussionBody.AppendFormat( "<p>Click <a href='{0}/{1}?ID={2}'>here</a> to view the details of the request.</p>", __Context.Web.Url, sourceList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url, item.ID.ToString());
DiscussionBody.Append( "<p>To discuss this request, click Reply at the top of this discussion item.</p>");
#endregion
// Set the Body of the list item.
discussionItem[ SPBuiltInFieldId.Body] = DiscussionBody.ToString();
// Save the changes to the discussion item
discussionItem.Update();
DiscussionItem = discussionItem.ID;
//DiscussionLink = discussionItem.Url + "," + discussionItem.Title;
return ActivityExecutionStatus.Closed;
}
#endregion
}
}
Here is the entry I put in my wss.actions file:
< Action Name="Create Discussion Item"
ClassName="MyCo.Workflow.Actions.CreateDiscussionItemActivity"
Assembly="MyCo.Workflow.Actions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b6dcb01d0aacda27"
AppliesTo="all"
Category="List Actions">
< RuleDesigner Sentence="Create discussion item in %1 to %2 (Output to %3)">
< FieldBind Field="ListId,ListItem" Text="this list" Id="1" DesignerType="ChooseListItem" />
< FieldBind Field="ToListId" Text="this list" Id="2" DesignerType="ListNames" />
< FieldBind Field="DiscussionItem" Text="variable" Id="3" DesignerType="ParameterNames" />
</ RuleDesigner>
< Parameters>
< Parameter Name="ListId" Type="System.String, mscorlib" Direction="In" />
< Parameter Name="ListItem" Type="System.Int32, mscorlib" Direction="In" />
< Parameter Name="DiscussionItem" Type="System.Int32, mscorlib" Direction="Out" />
< Parameter Name="ToListId" Type="System.String, mscorlib" Direction="In" />
< Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext,Microsoft.SharePoint.WorkflowActions" Direction="In" />
</ Parameters>
</ Action>
I have seen many people asking this same question, but no responses yet. Any advice will be most welcome.
Thanks,
Mark Stokes  |  |
|  | I never found an answer to this.
Since I am only working in a pilot environment, I simply write the URL back to the original list item in the activity code. This is not a solution for our production system, but worked arounf the issue for now. I'd love to hear if anyone does come up with a solution to this.
Mark  |  |
|
|
|
|
|
|