初期化フックは、アクションの開始時に複雑な初期化を実行します。例えば、このフックを使用すると、フィールドをリセットしたり、アクションのタイプに応じて、フィールドに異なる値を割り当てたりできます。
以下のコードは、ユーザーが障害を別のユーザーに再割り当てしようとするときに実行されるフックです。このフックは、再割り当てアクションの開始時に、action_reason フィールドの内容をクリアします。 このフィールドの動作が、「必須」に設定されている場合、ユーザーは、障害を再割り当てする理由を入力する必要があります。
Sub swbug_Initialization(actionname, actiontype)
' actionname As String
' actiontype As Long
' action = reassign
' Empty the string at the beginning of the action
SetFieldValue "action_reason", ""
End Sub
sub swsub_Initialization {
my($actionname, $actiontype) = @_;
# $actionname as string scalar
# $actiontype as long scalar
# action is reassign
# do any setup for the action here
# Empty the string at the beginning of the action
$entity->SetFieldValue("action_reason", "");
}