This article shows you how to add a CheckBox to the UI part of your FIM custom workflow.
Add the following functions to your workflow's UI class:
#Region "CheckBox Functions"
Private
Function
AddTableRowCheckBox(
ByVal
labelText
As
[
String
],
controlID
], _
defaultValue
Boolean
])
TableRow
Dim
row
New
TableRow()
labelCell
TableCell()
controlCell
label
Label()
checkbox
CheckBox()
label.Text = labelText
label.CssClass =
MyBase
.LabelCssClass
labelCell.Controls.Add(label)
checkbox.ID = controlID
checkbox.Checked = defaultValue
controlCell.Controls.Add(checkbox)
row.Cells.Add(labelCell)
row.Cells.Add(controlCell)
Return
End
GetIsChecked(
checkBoxID
)
checkBox
CheckBox =
DirectCast
(
Me
.FindControl(checkBoxID), CheckBox)
checkBox.Checked
Sub
SetIsChecked(
,
isChecked
If
checkBox IsNot
Nothing
Then
checkBox.Checked = isChecked
Else
checkBox.Checked =
True
SetCheckBoxReadOnlyOption(
textBoxID
[readOnly]
.FindControl(textBoxID), CheckBox)
checkBox.Enabled =
Not
#End Region
In your workflow's Activity code you need to define a Boolean property which will represent whether the CheckBox is ticked in the FIM Portal workflow configuration:
Public
Shared
MyCheckBoxProperty
DependencyProperty = DependencyProperty.Register(
"MyCheckBox"
GetType
(System.
),
(MyActivity))
<Description(
"Please specify the target attribute"
)> _
<DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
<Browsable(
Property
MyCheckBox()
Get
.GetValue(MyActivity.MyCheckBoxProperty), [
Set
value
.SetValue(MyActivity.MyCheckBoxProperty, value)
You also need to modify the default methods of the UI class to render the CheckBox.
Overrides
GenerateActivityOnWorkflow(
workflow
SequentialWorkflow)
Activity
.ValidateInputs()
MyActivity
MyActivity()
MyActivity.MyCheckBox =
.GetIsChecked(
"bMyCheckBox"
LoadActivitySettings(
activity
Activity)
MyActivity = TryCast(activity, MyActivity)
MyActivity IsNot
.SetIsChecked(
, MyActivity.MyCheckBox)
PersistSettings()
ActivitySettingsPartData
data
ActivitySettingsPartData()
data(
) =
RestoreSettings(
ActivitySettingsPartData)
data IsNot
(data(
))
SwitchMode(
mode
ActivitySettingsPartMode)
= (mode = ActivitySettingsPartMode.View)
.SetCheckBoxReadOnlyOption(
, [readOnly])
Protected
CreateChildControls()
controlLayoutTable
Table
controlLayoutTable =
Table()
controlLayoutTable.Width = Unit.Percentage(100.0)
controlLayoutTable.BorderWidth = 0
controlLayoutTable.CellPadding = 2
' The following line adds the CheckBox
controlLayoutTable.Rows.Add(
.AddTableRowCheckBox(
"MyTitle:"
.Controls.Add(controlLayoutTable)
.CreateChildControls()
To access the CheckBox value in your Activity code simply use Me.MyCheckBox.