This article shows you how to add a CheckBox to the UI part of your FIM custom workflow.
Table of Contents<
MIM 2016: How to Add a CheckBox to a Custom Workflow UI
This article shows you how to add a CheckBox to the UI part of your FIM cust/h2>
Applies to
- FIM 2010 and later,
- MIM 2016 all versions
UI code functions
Add the following functions to your workflow's UI class:
#Region "CheckBox Functions"
Private
Function
AddTableRowCheckBox(ByVal
labelText As
[String],
ByVal
controlID As
[String], _
ByVal
defaultValue As
[Boolean])
As
TableRow
Dim
row As
New
TableRow()
Dim
labelCell As
New
TableCell()
Dim
controlCell As
New
TableCell()
Dim
label As
New
Label()
Dim
checkbox As
New
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
row
End
Function
Private
Function
GetIsChecked(ByVal
checkBoxID As
String)
As
Boolean
Dim
checkBox As
CheckBox = DirectCast(Me.FindControl(checkBoxID),
CheckBox)
Return
checkBox.Checked
End
Function
Private
Sub
SetIsChecked(ByVal
checkBoxID As
String,
ByVal
isChecked As
Boolean)
Me.FindControl(checkBoxID),
CheckBox)
Return
checkBox.Checked
End
Function
Private
Sub
SetIsChecked(ByVal
checkBoxID As
String,
Dim
checkBox As
CheckBox = DirectCast(Me.FindControl(checkBoxID),
CheckBox)
If
checkBox IsNot Nothing
Then
checkBox.Checked = isChecked
Else
checkBox.Checked =
True
End
If
End
Sub
Private
Sub
SetCheckBoxReadOnlyOption(ByVal
textBoxID As
String,
ByVal
[readOnly] As
Boolean)
Dim
checkBox As
CheckBox = DirectCast(Me.FindControl(textBoxID),
CheckBox)
checkBox.Enabled =
Not
[readOnly]
End
Sub
#End Region
Define a Boolean property in the Activity code
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 As
DependencyProperty = DependencyProperty.Register("MyCheckBox",
GetType(System.Boolean),
GetType(MyActivity))
<Description("Please specify the target attribute")>
_
<DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
<Browsable(True)> _
Public
Property
MyCheckBox() As
Boolean
Get
Return
DirectCast(MyBase.GetValue(MyActivity.MyCheckBoxProperty), [Boolean])
End
Get
Set(ByVal
value As
Boolean)
MyBase.SetValue(MyActivity.MyCheckBoxProperty, 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 CheckBox.
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.MyCheckBox =
Me.GetIsChecked("bMyCheckBox")
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.SetIsChecked("bMyCheckBox",
MyActivity.MyCheckBox)
End
If
End
Sub
Public
Overrides
Function PersistSettings() As
ActivitySettingsPartData
Dim
data As
New
ActivitySettingsPartData()
data("MyCheckBox") =
Me.GetIsChecked("bMyCheckBox")
Return
data
End
Function
As
ActivitySettingsPartData
Dim
data As
New
ActivitySettingsPartData()
data("MyCheckBox") =
Me.GetIsChecked("bMyCheckBox")
Return
data
Public
Overrides
Sub RestoreSettings(ByVal
data As
ActivitySettingsPartData)
If
data IsNot Nothing
Then
Me.SetIsChecked("bMyCheckBox",
DirectCast(data("MyCheckBox"),
Boolean))
End
If
End
Sub
Public
Overrides
Sub SwitchMode(ByVal
mode As
ActivitySettingsPartMode)
Dim
[readOnly] As
Boolean
= (mode = ActivitySettingsPartMode.View)
Me.SetCheckBoxReadOnlyOption("bMyCheckBox",
[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 line adds the CheckBox
controlLayoutTable.Rows.Add(Me.AddTableRowCheckBox("MyTitle:",
"bMyCheckBox",
True))
Me.Controls.Add(controlLayoutTable)
MyBase.CreateChildControls()
End
Sub
Using the value in your Activity code
To access the CheckBox value in your Activity code simply use Me.MyCheckBox.
References
- http://msdn.microsoft.com/en-us/library/ff859524.aspx
- http://www.wapshere.com/missmiis/adding-a-checkbox-to-a-fim-custom-workflow-ui
MIM 2016: How to Add a CheckBox to a Custom Workflow UI
This article shows you how to add a CheckBox to the UI part of your FIM cust/h2>
Applies to
- FIM 2010 and later,
- MIM 2016 all versions
UI code functions
Add the following functions to your workflow's UI class:
#Region "CheckBox Functions" Private
Function
AddTableRowCheckBox(ByVal
labelText As
[String],
ByVal
controlID As
[String], _ ByVal
defaultValue As
[Boolean])
As
TableRow Dim
row As
New
TableRow() Dim
labelCell As
New
TableCell() Dim
controlCell As
New
TableCell() Dim
label As
New
Label() Dim
checkbox As
New
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
row End
Function Private
Function
GetIsChecked(ByVal
checkBoxID As
String)
As
Boolean Dim
checkBox As
CheckBox = DirectCast(Me.FindControl(checkBoxID),
CheckBox) Return
checkBox.Checked End
Function Private
Sub
SetIsChecked(ByVal
checkBoxID As
String,
ByVal
isChecked As
Boolean).FindControl(checkBoxID),
CheckBox) Return
checkBox.Checked End
Function Private
Sub
SetIsChecked(ByVal
checkBoxID As
String,
Dim
checkBox As
CheckBox = DirectCast(Me.FindControl(checkBoxID),
CheckBox) If
checkBox IsNot Nothing
Then checkBox.Checked = isChecked Else checkBox.Checked =
True End
If End
Sub Private
Sub
SetCheckBoxReadOnlyOption(ByVal
textBoxID As
String,
ByVal
[readOnly] As
Boolean) Dim
checkBox As
CheckBox = DirectCast(Me.FindControl(textBoxID),
CheckBox) checkBox.Enabled =
Not
[readOnly] End
Sub #End Region
Define a Boolean property in the Activity code
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 As
DependencyProperty = DependencyProperty.Register("MyCheckBox",
GetType(System.Boolean),
GetType(MyActivity)) <Description("Please specify the target attribute")>
_ <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _ <Browsable(True)> _ Public
Property
MyCheckBox() As
Boolean Get Return
DirectCast(MyBase.GetValue(MyActivity.MyCheckBoxProperty), [Boolean]) End
Get Set(ByVal
value As
Boolean) MyBase.SetValue(MyActivity.MyCheckBoxProperty, value) End
Set End
PropertyAdd the CheckBox to the UI
You also need to modify the default methods of the UI class to render the CheckBox.
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.MyCheckBox =
Me.GetIsChecked("bMyCheckBox") 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.SetIsChecked("bMyCheckBox",
MyActivity.MyCheckBox) End
If End
Sub Public
Overrides
Function PersistSettings() As
ActivitySettingsPartData Dim
data As
New
ActivitySettingsPartData() data("MyCheckBox") =
Me.GetIsChecked("bMyCheckBox") Return
data End
Function As
ActivitySettingsPartData Dim
data As
New
ActivitySettingsPartData() data("MyCheckBox") =
Me.GetIsChecked("bMyCheckBox") Return
data Public
Overrides
Sub RestoreSettings(ByVal
data As
ActivitySettingsPartData) If
data IsNot Nothing
Then Me.SetIsChecked("bMyCheckBox",
DirectCast(data("MyCheckBox"),
Boolean)) End
If End
Sub Public
Overrides
Sub SwitchMode(ByVal
mode As
ActivitySettingsPartMode) Dim
[readOnly] As
Boolean
= (mode = ActivitySettingsPartMode.View) Me.SetCheckBoxReadOnlyOption("bMyCheckBox",
[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 line adds the CheckBox controlLayoutTable.Rows.Add(Me.AddTableRowCheckBox("MyTitle:",
"bMyCheckBox",
True)) Me.Controls.Add(controlLayoutTable) MyBase.CreateChildControls() End
Sub
Using the value in your Activity code
To access the CheckBox value in your Activity code simply use Me.MyCheckBox.
References
- http://msdn.microsoft.com/en-us/library/ff859524.aspx
- http://www.wapshere.com/missmiis/adding-a-checkbox-to-a-fim-custom-workflow-ui