Lists and Display rules inside custom actions

8min

After creating the Class library (.Net 6) project and adding the Procesio NuGet package you will need to complete the two mandatory requirements in order to implement your classes to become proper custom action.

  • Inherit the IAction interface. This is mandatory because Procesio needs the Execute method in order to run your action within a flow. This is where you will add the logic of whatever behavior you need the action to have.
  • Use proper attributes for your properties to define what type and use they have within your new action. These attributes are necessary for Procesio to create the Action Template, which is like a contract used for the UI to dynamically interpret and display any type of provided action correctly within the platform.

It is important to note that once the custom action is added by uploading your NuGet file it can be used for any of your processes and that it can not be updated, for this you will need to rebuild the NuGet package with a different version number, then create it again in the process designer.

Example of full properties implementation

C#


The accepted types for a property are:

  • int
  • string
  • boolean
  • double
  • DateTime

We do not accept at this point user defined types or Nullable types. The value of a property in the designer will be the DefaultValue from the FEDecorator. If that property is not required via the Validator decorator and  DefaultValue is not defined either, then we will use the default value of the corresponding data type from C# (0 for int and double, false for boolean, etc.). The same applies if the default value is deleted by the user and no other value is specified. 

Using lists

To use a list inside a Custom Action, one would have to define an IEnumerable property of the required type. To this end, there are several cases where this applies:

1. List of primitive data type

C#


The list usage is quite straightforward in this case.

2. List of custom data type

C#


This list is a classic IEnumerable of objects, but their content is dynamic, receiving a JSON value as input. The action developer must know the JSON structure to work with.

3. List of files

C#


This is a list of files, where each file is sent as a data stream, accessible through the Action.Core.FileModel type. 

The FileModel type has only two properties: Name and File. The Name property holds the file name, and the File property holds the file stream which can be used to retrieve the file content.

Example in using the file stream when iterating through the File list:

C#


Display rules

To control the order in which the frontend components will be displayed, we use the OrderId and RowID properties. The OrderId applies to Tab components and it controls the order in which tabs are displayed. The RowId controls the order of the components inside a parent (a tab, modal, or side panel). All components inside a parent component should have a unique RowID, otherwise, the display order will be inconsistent. Multiple components can have the same RowId as long as they belong to different parent components. An example of usage is:

C#


Another use case for a custom action would be to order ascending or descending a list of numbers that you input in your flow.

Document image


Besides the examples provided in this document, you can also follow the given example of custom actions provided by the Procesio Core project - Custom template action.