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.


9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi Roy,
    I have find the version 2.0 of the SPDWorkflowStringActions plugins on CodePlex, I use SharePoint 2016. The feature is deploy and I view the new string action on the SPD 2013, I could add the action in my workflow 2010. But when I try to publish the workflow, I receive an error like the type SPDWorkflowStringActions.Length is not authorize in the configuration file of the application.
    I have modify the web.config of my main sharepoint site on my dev server.

    Thank you !

    ReplyDelete
  3. For anybody who search to work with this plugin in SharePoint 2016. I finish by resolve my issue.

    1. I have take the source code and open it in VS 2019.
    2. I have change the reference to the SharePoint.dll
    3. I have try to compile the source code.
    4. I have correct the error in the source code.
    5. I have compile again and generate the new SPDWorkflowStringActions.dll
    6. I have disable the SPDWorkflowStringActions function in the SharePoint admin. Because, I could not replace my DLL file who are read only.
    7. I have reactivate theSPDWorkflowStringActions function in the SharePoint admin.
    8. I have open my SharePoint Designer 2013 all the new string option are present.
    9. I have test the lenth() function and receive the same error .
    10. I have find than Microsoft have earase somes line in the WebConfig file about .net assembly.

    You need to add the line below in all webconfig file in the SharePoint server.















    You need to check if the line below are present in the file at the right place.

    ";
    ";
    ";
    ";
    ";
    ";
    ";
    ";


    Make this modification in all your webconfig !
    First time I have only modify the webconfig file of my principal sharepoint web site.

    11. Open a cmd in admin mode and make a iisreset.
    This commande reload the SharePoint Site to read again the webconfig file.

    12. Close SharePoint Designer 2013 if it's always open.

    13. OPen SharePoint Designer 2013 again and connect to your site collection.

    14. Try to create or modify a SharePoint 2010 WorkFlow !

    The new String option are not availaible in the SharePoint 2013 workflow edition.

    15. If you go in the action Menu you will find the new string functions.

    Add one of them in the workflow editor and try to publish.

    In my case all work now without any error about authorization.

    Hope this help somebody !

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions\" TypeName="*" Authorized="True"

    ReplyDelete
  7. Dont forget to add the < before the authorizedType and the />"; at the end of the True" for each line of code !



    authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions\" TypeName="*" Authorized="True" />";
    ";
    ";
    Here is the invisible line of th first post.
    Dont forget to add < before the authorizedType and the


    authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions\" TypeName="*" Authorized="True"


    authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions\" TypeName="*" Authorized="True"


    authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions\" TypeName="*" Authorized="True"


    authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions\" TypeName="*" Authorized="True"

    authorizedType Assembly="SPDWorkflowStringActions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3825586d873cffa1" Namespace="SPDWorkflowStringActions" TypeName="*" Authorized="True"

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeBinaryOperatorExpression" Authorized="True

    authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePrimitiveExpression" Authorized="True

    authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodInvokeExpression" Authorized="True

    authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodReferenceExpression" Authorized="True

    authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeFieldReferenceExpression" Authorized="True"

    authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeThisReferenceExpression" Authorized="True

    authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePropertyReferenceExpression" Authorized="True

    Dont forget to add the < before the authorizedType and the />"; at the end of the True" for each line of code !

    ReplyDelete