Custom Data Type

Last published at: May 2nd, 2023

What is a custom data type?

Custom data type is a data type used on a step property.

 

In reference to the above diagram, the “abortinstance” step has 1 property called “instanceID” that is “string” data type.  When the step is rendered within the workflow designer, the “condition” property is rendered as a textbox.

Custom data types

Custom data types can be configured using the data type screen of the FlowWright Configuration Manager.

When the “string” data type is rendered, it looks as follows:

Writing a custom data type

Custom data type can be written easily by implementing the “IDataType” interface.  The following code shows the actual code for the “string” data type.

Delete

Code block

[dataTypeData("string")]
    public class clsTextBox : IDataType2
    {
        /// <summary>
        /// Renders the specific control
        /// </summary>
        /// <param name="dataTypeContext"></param>
        /// <returns></returns>
        public string render(clsDataTypeContext dataTypeContext)
        {
            string sHTML = string.Empty;
            try
            {
                 TextBox oBox = new TextBox();
                 oBox.ID = dataTypeContext.controlID;
                 oBox.Width = Unit.Percentage(99);
 
                if (!string.IsNullOrWhiteSpace(dataTypeContext.selectedValue))
                {
                     oBox.Text = dataTypeContext.selectedValue;
                }
 
                 StringWriter stringWriter = new StringWriter();
                 HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
 
                 oBox.RenderControl(writer);
 
                 sHTML = stringWriter.ToString();
 
            }
            catch (Exception ex)
            {
                 dataTypeContext.writeError("deSystemDataTypes", ex, priorityLevel.medium, "", "DataType", dataTypeContext.controlID);
 
            }
            return (sHTML);
        }
    }

Data type interface “IDataType2” has one single method that needs to be implemented:

public string render(clsDataTypeContext dataTypeContext)

The return from the “render” function is to return a HTML string to render the HTML controls for the property.

Configuring the custom data type

Once the custom data type is compiled into a DLL, it can be configured through the FlowWright Configuration Manager.  Place the DLL file within the FlowWright directory:

C:\inetpub\wwwroot\cDevWorkflow\bin 

Navigate to the “Data Types” page within the Configuration Manager.

Use the data type auto detect and configure feature to configure, select “Utils -> Auto Detect” menu item:

 Auto detect feature should automatically detect the new data type and show you within the list:

Select the new data type and select “Manage -> Configure” to configure the data type.  

 Alternatively, if you know the information, you can also use the “Actions -> Create” menu item from the data type page to manually configure the data type within FlowWright.

 Here’s what the configuration looks for the “string” data type step:

Once the data type is configured, data type can be used for defining properties for a given step.

Building and configuring an advanced data type

Advanced data types are data types that perform complex operations and store the value in a property. Data type “SelectUsers” is one of them.  The following is the actual code for the data type:

Delete

Code block

[dataTypeData("selectUsers")]
    public class clsSelectUsers : IDataType2
    {
        /// <summary>
        /// Renders the specific control
        /// </summary>
        /// <param name="dataTypeContext"></param>
        /// <returns></returns>
        public string render(clsDataTypeContext dataTypeContext)
        {
            string sHTML = string.Empty;
            try
            {
                 StringWriter stringWriter = new StringWriter();
                 HtmlTextWriter writer = new HtmlTextWriter(stringWriter);
 
                 Button oBtn = new Button();
                 oBtn.ID = dataTypeContext.controlID;
                 oBtn.Text = "...";
                 oBtn.OnClientClick = string.Format("window.open('deSelectUsers.aspx?fieldName={0}&type=user','','resizable=1,status=1,scrollbars=1,width=550,height=500');", dataTypeContext.controlID);
 
                 oBtn.UseSubmitBehavior = false;
 
                 oBtn.RenderControl(writer);
 
                 sHTML = HttpUtility.HtmlDecode(stringWriter.ToString());
 
            }
            catch (Exception ex)
            {
                 dataTypeContext.writeError("deSystemDataTypes", ex, priorityLevel.medium, "", "DataType", dataTypeContext.controlID);
 
            }
            return (sHTML);
        }
}


The above code renders a button for the property and the button launches the window for user selection.

 Clicking the button will display the following User selection dialog: