Los enganches de inicialización realizan inicializaciones complejas al principio de una acción. Por ejemplo, puede utilizar este enganche para restablecer campos o asignar valores diferentes a campos en base al tipo de acción.
El siguiente código es un enganche que se ejecuta cuando un usuario intenta reasignar un defecto a otro usuario. El enganche borra el contenido del campo motivo_acción al principio de la acción de reasignar. Si el comportamiento de este campo se establece en Obligatorio, el usuario debe proporcionar un motivo para reasignar el defecto.
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", "");
}