Welcome on my SharePoint 2010 blog

Hello,

My name's Roy. I'm a dutch SharePoint & BI consultant/architect at Advantive B.V. At this moment I'm busy with some big SharePoint 2010 projects in The Netherlands. In all the projects I've got different roles, like: Business consultancy, Lead Consultant, Architect (logical and technical), Development and Teaching/courses.

Products where you can ask me about are: SharePoint, Visual Studio, SQL Server, PowerPivot, Analysis and Reporting Services, Visio Services, InfoPath, PerformancePoint Services, Team Foundation Server, Office line.

I love to work and to write about Microsoft SharePoint 2010 so, feel free and read/comment my Blogs!

Greetz.

Thursday, September 9, 2010

Building custom actions in SP Designer 2010

Situation:

When you want to use the managed metadata fields in SharePoint Designer 2010 in e.g. an e-mail message then you get the following information back from the system:

<Guid>|<Termtext>

If you want to split this string array (devided by a pipeline) with SharePoint Designer, it's by default not possible. SharePoint Designer doesn't have any actions to split a string or a string array.

Solution:

With Visual Studio 2010 I created a feature with a feature receiver. This feature will activate a part in the web.config file:

"<authorizedType Assembly=\"SPDWorkflowStringActions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b2222d748ee56b1\" Namespace=\"SPDWorkflowStringActions\" TypeName=\"*\" Authorized=\"True\" />";

Next to that you will create some string methods and necessary properties into separate classes. I have the following:



Next to the string methods and properties (the intelligence) you need to make it User Friendly in SPD2010. Therefore I added a predefined XML-file (with the extension .actions). In this file I create the buttons/links that will make it possible that I can use my string options (the following is a part of this XML).

<WorkflowInfo>
  <Actions Sequential="then" Parallel="and">
    <Action Name="Contains()"
     ClassName="SPDWorkflowStringActions.Contains"
     Assembly="SPDWorkflowStringActions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b2222d748ee56b1"
     AppliesTo="all" Category="String Actions">
      <RuleDesigner Sentence="Determine if %1 contains a value of %2 and output a value of true or false to %3." AppliesTo="all" Name="Contains">
        <FieldBind Field="InParam1" Id="1" Text="String"/>
        <FieldBind Field="InParam2" Id="2" Text="String"/>
        <FieldBind Field="OutResult1" DesignerType="ParameterNames" Id="3" Text="Output result #1" />
      </RuleDesigner>
      <Parameters>
        <Parameter Name="InParam1" Type="System.String, mscorlib" Direction="In" InitialValue="empty" />
        <Parameter Name="InParam2" Type="System.String, mscorlib" Direction="In" InitialValue="empty" />
        <Parameter Name="OutResult1" Type="System.String, mscorlib" Direction="Out" />
      </Parameters>
    </Action>
    <Action Name="EndsWith()"
     ClassName="SPDWorkflowStringActions.EndsWith"
     Assembly="SPDWorkflowStringActions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5b2222d748ee56b1"
     AppliesTo="all" Category="String Actions">
      <RuleDesigner Sentence="Determine if %1 ends with a value of %2, and output a value of true or false to %3." AppliesTo="all" Name="EndsWith">
        <FieldBind Field="InParam1" Id="1" Text="Input parameter #1"/>
        <FieldBind Field="InParam2" Id="2" Text="Input parameter #2"/>
        <FieldBind Field="OutResult1" DesignerType="ParameterNames" Id="3" Text="Output result #1" />
      </RuleDesigner>
      <Parameters>
        <Parameter Name="InParam1" Type="System.String, mscorlib" Direction="In" InitialValue="empty" />
        <Parameter Name="InParam2" Type="System.String, mscorlib" Direction="In" InitialValue="empty" />
        <Parameter Name="OutResult1" Type="System.String, mscorlib" Direction="Out" />
      </Parameters>
    </Action>

This part will be added to the default SharePoint .actions file.

When we deploy the project in Visual Studio 2010 and activate the WebApp scoped feature we'll can use the buttons in SharePoint designer.

For more information please let me know and I can send you the project files.


No comments:

Post a Comment