Your first Custom action

Avatar

By Sorin Pavel

updated 24 days ago

In the following article we will learn how to create a simple Custom action and how to add it to our flow.

  1. Open Visual Studio.
  2. Create a New project of type Class Library (.Net Core 3.1).
  3. In this example we will call the action FullName.
  4. Add the nuget to your project:
    • go to Tools → Nuget Package Manager → Manage NuGet Packages for Solution
    • from Package Source select your Github connection
    • from Browse select the Ringhel.Procesio.Action.Core package
    • check the name of your project and click Install
  5. In the Solution explorer right click on your project and select Edit project file and replace the text with


    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
        <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
        <TargetsForTfmSpecificBuildOutput>
          $(TargetsForTfmSpecificBuildOutput);IncludeDepsInPackage
        </TargetsForTfmSpecificBuildOutput>
        <AllowedOutputExtensionsInPackageBuildOutputFolder>
          $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb;.json
        </AllowedOutputExtensionsInPackageBuildOutputFolder>
        <Version>1.3.6.4</Version>
      </PropertyGroup>
    
    
      <ItemGroup>
        <PackageReference Include="Ringhel.Procesio.Action.Core" Version="1.5.1.2" />
      </ItemGroup>
    
      <Target Name="IncludeDepsInPackage">
        <ItemGroup>
          <BuildOutputInPackage Include="$(OutDir)*" />
        </ItemGroup>
      </Target>
    </Project>
  6. Create your custom action in a new class
  7. Include the following namespaces in your Custom Action class definition
    using System.Threading.Tasks;
    using Ringhel.Procesio.Action.Core.Models;
    using Ringhel.Procesio.Action.Core;
    using Ringhel.Procesio.Action.Core.ActionDecorators;
    using Ringhel.Procesio.Action.Core.Utils;
  8. We will provide you the full code for a custom action that will concatenate two strings that will be provided as inputs
    namespace concatenate
    {
        [ClassDecorator(Name = "Name of Action", Shape = ActionShape.Square, Description = "Description of the custom 
    action", Classification = Classification.cat1,
            Tooltip = "Tooltip of the action", IsTestable = false)]
        [FEDecorator(Label = "Configure formatting", Type = FeComponentType.Side_pannel, Tab = "Presentation", 
    Parent = "Side_Panel_Parent", RowId = 1)]
        [Permissions(CanDelete = true, CanDuplicate = true, CanAddFromToolbar = true)]
        public class Class1 : IAction
        {
            [FEDecorator(Label = "First name", Type = FeComponentType.Text, Parent = "Side_Panel_Parent", RowId = 1)]
            [BEDecorator(IOProperty = Direction.Input)]
            [Validator(IsRequired = true)]
            public string FirstName { get; set; }
            [FEDecorator(Label = "Last name", Type = FeComponentType.Text, Parent = "Side_Panel_Parent", RowId = 2)]
            [BEDecorator(IOProperty = Direction.Input)]
            [Validator(IsRequired = true)]
            public string LastName { get; set; }
            [FEDecorator(Label = "String after format",Type = FeComponentType.Text,Parent = "Side_Panel_Parent",RowId = 3)]
            [BEDecorator(IOProperty = Direction.Output)]
            [Validator(IsRequired = true)]
            public string FullName { get; set; }
            public async Task Execute()
            {
                FullName = string.Concat(FirstName, " ", LastName);
            }
        }
    }
  9. The above code can be altered to create your own specific custom action or left as is.
  10. To generate your own nuget you will need to right click your project in the Solution explorer and select Properties and in the Package section you will need to:
    • check Generate Nuget package on build
    • before each build you will need to come here and change the Package version, for example from 1.0.0 to 1.0.0.0.1
  11. From the Visual Studio main menu select Build Solution from the Build dropdown
  12. To find the newly created nuget you must right click on your project from the Solution explorer and select Open folder in file explorer and navigate to Bin > Debug.
  13. To add the Custom action to your project switch to the Custom actions section.
  14. Click the Create custom action button on the bottom left corner.
  15. Give the action a name and upload or drag and drop the file and click Save.
  16. The newly created Custom action will appear in the Custom actions list and you can drag it on the canvas like any other action.

We provided the code used to create the custom actions present on the platform on Github.

       Custom action decorators 

Did this answer your question?