This article shows you how to add a RadioButtonList to the UI part of your FIM custom workflow.


UI code functions

Add the following functions to your workflow's UI class:
#Region "Radio Functions"
    Private Function AddTableRowRadioList(ByVal labelText As [String], ByVal controlID As [String], _
                                          ByVal radioOptions As String(), _
                                          ByVal defaultValue As [String]) As TableRow
        Dim row As New TableRow()
        Dim labelCell As New TableCell()
        Dim controlCell As New TableCell()
        Dim label As New Label()
        Dim radioList As New RadioButtonList()
        Dim item As String

        label.Text = labelText
        label.CssClass = MyBase.LabelCssClass

        radioList.ID = controlID
        For Each item In radioOptions
            radioList.Items.Add(New ListItem(item, item))
        radioList.SelectedValue = defaultValue
        radioList.RepeatDirection = RepeatDirection.Horizontal
        Return row
    End Function

    Private Function GetRadioSelection(ByVal radioListID As String) As String
        Dim radioList As RadioButtonList = DirectCast(Me.FindControl(radioListID), RadioButtonList)
        Return radioList.SelectedValue
    End Function

    Private Sub SetRadioSelection(ByVal radioListID As String, ByVal radioSelection As String)
        Dim radioList As RadioButtonList = DirectCast(Me.FindControl(radioListID), RadioButtonList)
        If radioList IsNot Nothing Then
            radioList.SelectedValue = radioSelection
            radioList.SelectedValue = radioList.Items.Item(0).Text
        End If
    End Sub

    Private Sub SetRadioListReadOnlyOption(ByVal radioListID As String, ByVal [readOnly] As Boolean)
        Dim radioList As RadioButtonList = DirectCast(Me.FindControl(radioListID), RadioButtonList)
        radioList.Enabled = Not [readOnly]
    End Sub

#End Region


Define a String property in the Activity code

In your workflow's Activity code you need to define a String property which will return the option selected in the FIM Portal workflow configuration:
    Public Shared MyRadioProperty As DependencyProperty = DependencyProperty.Register("MyRadio", GetType(System.String), GetType(MyActivity))
    <Description("Please specify the target attribute")> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Browsable(True)> _
    Public Property MyRadio() As String
            Return DirectCast(MyBase.GetValue(MyActivity.MyRadioProperty), [String])
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(MyActivity.MyRadioProperty, value)
        End Set
    End Property


Add the CheckBox to the UI

You also need to modify the default methods of the UI class to render the RadioButtonList.
    Public Overrides Function GenerateActivityOnWorkflow(ByVal workflow As SequentialWorkflow) As Activity
        If Not Me.ValidateInputs() Then
            Return Nothing
        End If
        Dim MyActivity As New MyActivity()
        MyActivity.MyRadio = Me.GetRadioSelection("txtMyRadio")
        Return MyActivity
    End Function

    Public Overrides Sub LoadActivitySettings(ByVal activity As Activity)
        Dim MyActivity As MyActivity = TryCast(activity, MyActivity)
        If MyActivity IsNot Nothing Then
            Me.SetRadioSelection("txtMyRadio", MyActivity.MyRadio)
        End If
    End Sub

    Public Overrides Function PersistSettings() As ActivitySettingsPartData
        Dim data As New ActivitySettingsPartData()
        data("MyRadio") = Me.GetRadioSelection("txtMyRadio")
        Return data
    End Function

    Public Overrides Sub RestoreSettings(ByVal data As ActivitySettingsPartData)
        If data IsNot Nothing Then
            Me.SetRadioSelection("txtMyRadio", DirectCast(data("MyRadio"), String))
        End If
    End Sub

    Public Overrides Sub SwitchMode(ByVal mode As ActivitySettingsPartMode)
        Dim [readOnly] As Boolean = (mode = ActivitySettingsPartMode.View)
        Me.SetRadioListReadOnlyOption("txtMyRadio", [readOnly])
    End Sub

    Protected Overrides Sub CreateChildControls()
        Dim controlLayoutTable As Table
        controlLayoutTable = New Table()
        controlLayoutTable.Width = Unit.Percentage(100.0)
        controlLayoutTable.BorderWidth = 0
        controlLayoutTable.CellPadding = 2
        ' The following lines add the RadioButtonList
        Dim radioOptions As String() = {"option1", "option2", "option3"}
        controlLayoutTable.Rows.Add(Me.AddTableRowRadioList("My Caption:", "txtLoggingLevel", loggingOptions, "Normal"))

    End Sub


Using the value in your Activity code

To access the CheckBox value in your Activity code simply use Me.MyRadio.