Question

I've been following several examples regarding custom actions. I've been trying to deploy my own one, but although I can see the action inside SPD, when selected it doesn't appear in the workflow step.

What I am trying to do is to perform a field lookup in both CSVString and ReleaseID properties, and a list name lookup in SecondaryListName.

I have VS and SP both on the same development box so there aren't multiple front ends. There are several web applications but I have made sure I have updated the correct web.config.

The namespace I'm using is "CustomActivity" and the class (which is public) is called "StringIteration".

I have deployed the dll to the GAC successfully.

The CustomActivity.actions file looks like:

<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
    <Actions Sequential="then" Parallel="and">
        <Action Name="String Iterate To New List Items"
            ClassName="CustomActivity.StringIteration"
            Assembly="CustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82239858eda182a1"
            Category="My Custom Activities"
            AppliesTo="all">
            <RuleDesigner Sentence="Get CSV values from field %1 using request ID %2 and insert to list %3">
                <FieldBind DesignerType="FieldNames" Id="1" Text="Field with CSV contents" Field="CSVString" />
                <FieldBind DesignerType="ListNames" Id="2" Text="List to add new records to" Field="SecondaryListName" />
                <FieldBind DesignerType="FieldNames" Id="3" Text="Release ID Field" Field="ReleaseID" />
            <Parameters>
                <Parameter Name="CSVString" Type="System.String, mscorlib" Direction="In" DesignerType="FieldNames" Description="Approver matrix list name." />
                <Parameter Name="SecondaryListName" Type="System.String, mscorlib" Direction="In" DesignerType="ListNames" Description="Approver matrix fields." />
                <Parameter Name="ReleaseID" Type="System.Int32, mscorlib" Direction="In" DesignerType="FieldNames" Description="Workflow variable output by this action." />
                <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In" DesignerType="Hide" />
            </Parameters>
        </Action>
    </Actions>
</WorkflowInfo>

I have updated the relevant web.config with:

<authorizedType Assembly="CustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82239858eda182a1" Namespace="CustomActivity.StringIteration" TypeName="*" Authorized="True" />

Any help would be greatly appreciated

Thanks

EDIT: As with this question, I am able to break the workflow by changing the assembly name inside the actions file. This causes an SPD error to be generated, therefore it must be reading the assembly correctly (I think).

Custom workflow activity for SP 2007 appears in Designer's action picker but won't add

EDIT 2:

I have updated my actions file following Tim's comments, but the same thing still happens:

<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
    <Actions Sequential="then" Parallel="and">
        <Action Name="String Iterate To New List Items"
            ClassName="CustomActivity.StringIteration"
            Assembly="CustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82239858eda182a1"
            Category="My Custom Activities"
            UseCurrentItem="true"
            AppliesTo="all">
            <RuleDesigner Sentence="Get CSV values from field %1 using request ID %2 and insert to list %3">
                <FieldBind DesignerType="FieldNames" Id="1" Text="Field with CSV contents" Field="CSVString" />
                <FieldBind DesignerType="FieldNames" Id="2" Text="Release ID Field" Field="ReleaseID" />
                <FieldBind DesignerType="ListNames" Id="3" Text="List to add new records to" Field="SecondaryListName" />
            </RuleDesigner>
            <Parameters>
                <Parameter Name="CSVString" Type="System.String, mscorlib" Direction="In" />
                <Parameter Name="ReleaseID" Type="System.Int32, mscorlib" Direction="In" />
                <Parameter Name="SecondaryListName" Type="System.String, mscorlib" Direction="In" />
                <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In" DesignerType="Hide" />
            </Parameters>
        </Action>
    </Actions>
</WorkflowInfo>

EDIT 3: Okay, so this goes from worse to even worse. I've steadily removed properties from the actions file (and dependancyproperties from the dll) until there is 1 property left. I've set this to be a DesignerType of TextArea and the dependancyproperty is a string. I've cleared the cache, reset IIS... and still nothing.

So now I'm wondering if it's something else? the code for the dll is:


namespace CustomActivity
{
    public partial class StringIteration : SequenceActivity
    {
        private string _updatedCSVString = "";


        public static DependencyProperty CSVStringProperty = DependencyProperty.Register("CSVString", typeof(string), typeof(StringIteration), new PropertyMetadata(""));
        [ValidationOption(System.Workflow.ComponentModel.Compiler.ValidationOption.Required)]
        public string CSVString
        {
            get
            {
                return (string)base.GetValue(StringIteration.CSVStringProperty);
            }
            set
            {
                base.SetValue(StringIteration.CSVStringProperty, value);
                _updatedCSVString = value;
            }
        }

        public StringIteration()
        {
            InitializeComponent();
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            CSVString = "Work please";
            return ActivityExecutionStatus.Closed;
        }
    }
}

and the new, trimmed down actions file is:


<?xml version="1.0" encoding="utf-8" ?>
<WorkflowInfo>
    <Actions Sequential="then" Parallel="and">
        <Action Name="String Iterate To New List Items"
            ClassName="CustomActivity.StringIteration"
            Assembly="CustomActivity, Version=1.0.0.0, Culture=neutral, PublicKeyToken=82239858eda182a1"
            Category="My Custom Activities"
            AppliesTo="all">
            <RuleDesigner Sentence="Get CSV values from field %1">
                <FieldBind Field="CSVStringProperty" DesignerType="TextArea" Id="1" Text="Field with CSV contents"/>
            </RuleDesigner>
            <Parameters>
                <Parameter Name="CSVStringProperty" Type="System.String, mscorlib" Direction="In" />
            </Parameters>
        </Action>
    </Actions>
</WorkflowInfo>

Thanks for everyones help so far! Any last ideas?

Was it helpful?

Solution 2

I followed this link and managed to get this demo working:

https://msmvps.com/blogs/sundar_narasiman/archive/2010/12/26/develop-custom-workflow-activity-for-sharepoint-2010-workflow.aspx

Rather than manually copying everything to where it should be I used Visual Studio Deploy to install everything, and the extra project to hold the actions file in the correct folder.

All working now.

Thanks for everyones help

OTHER TIPS

This is quite common when first developing an Action. Some things to check:

  1. Restart SharePoint Designer and IIS.
  2. Clear the SharePoint Designer Workflow Assembly Cache.
  3. Double check the strong name in the AuthorizedType element (use reflector to get the full signature of the Assembly).
  4. Check the syntax in your Actions file. It is my experience that if you get something wrong in there no errors are reported, it just doesn't work. (capitalisation, parameter types, etc)

If it is showing up in the list of activities, and by selecting it, nothing happens, in my experience, an exception is being caught somewhere, and probably logged. So try selecting it, and go right to the SharePoint logs.

Another idea, is that SharePoint designer is finicky and I haven't been able to determine when things are/are not cached. Have you tried simply closing/reopening SPD?

I have a working example I can compare with when I get in to the office.

Edit 1

I think there may be an issue in your <Parameters> section. I think your field bind's need to match your Parameters. Here's an example I did that created a List based on a URL, and outputted to a bool variable. I remember having issues until the Field and Name properties matched, and they must match your dependency properties.

<RuleDesigner Sentence="Create List named %1 at site %2 (IsSuccessful out to %3)">
  <FieldBind Field="ListName" Text="Custom List" DesignerType="TextArea" Id="1" />
  <FieldBind Field="SiteUrl" Text="Site" DesignerType="TextArea" Id="2" />
  <FieldBind Field="IsSuccessful" Text="WasListCreated" DesignerType="ParameterNames" Id="3" />
</RuleDesigner>
<Parameters>
  <Parameter Name="ListName" Type="System.String, mscorlib" Direction="In" />
  <Parameter Name="SiteUrl" Type="System.String, mscorlib" Direction="In" />
  <Parameter Name="IsSuccessful" Type="System.Boolean, mscorlib" Direction="Out" />
</Parameters>

Edit 2

Try adding the following attribute to your properties

[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]

Edit 3

Can you try to manually clear out the cache? The this post

I have same issue but now i found it . if your custom action not inserting in workflow steps , sure it's not authorize and check name of assembly name in your authorize script for example if my assembly name is "CustomActionDemo.dll" , assembly name in authorize code must be exactly : "CustomActionDemo"

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top