Ejemplo de enganche de valor de campo cambiado

Utilice enganches de valor cambiado para sincronizar campos o llevar a cabo otras tareas después de cambiar el valor de un campo.

En el ejemplo siguiente, el enganche comprueba el nombre del sistema operativo almacenado en el campo actual. Dependiendo del sistema operativo, el enganche asigna una número de versión al campo OS_version. Si aún no se ha establecido el campo actual y, por consiguiente, no contiene el nombre del sistema operativo, este enganche no establece el número de versión correspondiente.

VBScript

Sub OS_type_ValueChanged(fieldname)

    ' fieldname As String

    value = GetFieldValue(fieldname).GetValue()


     If value = "solaris" Then

       SetFieldValue "OS_version", "7.x"

     ElseIf value = "windows" Then

       SetFieldValue "OS_version", "95"

     ElseIf value = "hpux" Then

       SetFieldValue "OS_version", "10.x"

     End If

End Sub 

Perl

sub OS_type_ValueChanged  {

    my($fieldname) = @_;

    my($value);

    $value = $entity->GetFieldValue($fieldname)->GetValue();

    if ($value eq "solaris")  {

      $entity->SetFieldValue("OS_version", "7.x");

    } elsif ($value eq "windows")  {

      $entity->SetFieldValue("OS_version", "95");

    } elsif ($value eq "hpux")  {

      $entity->SetFieldValue("OS_version",  "10.x");

    }

} 

Comentarios