UnlockRecord

Descripción

Libera el bloqueo en el registro. Únicamente el usuario que posee el bloqueo o un usuario con privilegio de superusuario o un usuario que autoriza un diseñador de esquema, puede eliminar un bloqueo. Emite una excepción para indicar si el registro lo bloquea otro usuario, otra sesión o se ha actualizado el registro.

Los bloqueos de registro se liberan automáticamente cuando se confirma o se revierte la acción. Puede utilizar un enganche RECORD_SCRIPT_ALIAS para eliminar manualmente un bloqueo que se haya abandonado.

Para habilitar el desbloqueo manual de registro, para cada tipo de registro:
  • Cree un script de registro nuevo denominado Unlock.
  • Añada una acción nueva denominada Unlock del tipo RECORD_SCRIPT_ALIAS.
  • Establezca el script de registro de la acción al script Unlock.
Nota: Este método estuvo disponible en la versión 7.1.

Sintaxis

VBScript

entity.UnlockRecord  

Perl

$entity->UnlockRecord(); 
Identificador
Descripción
entity
Un objeto Entity que representa un registro de datos de usuario. En un enganche, si se omite esta parte de la sintaxis, se presupone el objeto Entity correspondiente al registro de datos actual (sólo VBScript).
Valor de retorno
Ninguno.

Ejemplos

VBScript

Function Defect_Unlock(param)
  ' param As Variant
  ' record type name is Defect
    REM add your hook code here
    Dim result
    Dim  session
    Dim locked_by
    ' Get the session
    set session = GetSession
    locked_by = GetLockOwner
    if (locked_by <> "") then
        Dim do_unlock
        do_unlock = session.IsUserSuperUser
        if (NOT do_unlock) then
            ' If the current user holds the lock, let them unlock it.
            Dim username
            username = session.GetUserLoginName
            if (username = locked_by) then
                do_unlock = true
            end if
        end if
        if (NOT do_unlock) then
            ' Additional options to "authorize" unlocking:
            '
            ' 1) allow if user is a member of an "unlock" group
            '    get user's groups, check if member
            '
            ' 2) allow for some privileged users, e.g. Security Administrator
            '    check session for the chosen privilege
            '
            ' 3) many other possibilities
        end if
        if (do_unlock) then
            UnlockRecord
        else
            result = "You are not allowed to unlock this record."
        end if
    end if
End Function

Perl

sub Defect_Unlock {
    my($result);
    my($param) = @_;
    # record type name is Defect
    if (ref ($param) eq "CQEventObject") {
        # add your CQEventObject parameter handling code here
    } elsif (ref (\$param) eq "SCALAR") {
        # add your scalar parameter handling code here
        # The Web clients support scalar parameter type only,
        # so the hook code added in the above section, needs to be duplicated here
    } else {
        # add your handling code for other type parameters here, for example:
        # die("Unknown parameter type");
    }
    $result = "";
    my $locked_by = $entity->GetLockOwner();
    if ($locked_by ne "") {
        my $do_unlock = $session->IsUserSuperUser();
        if (! $do_unlock) {
            # If the current user holds the lock, let them unlock it.
            my $username = $session->GetUserLoginName();
            if ($username =~ /^$locked_by$/i) {
                $do_unlock = 1;
            }
        }
        if (! $do_unlock) {
            # Additional options to "authorize" unlocking:
            #
            # 1) allow if user is a member of an "unlock" group
            #    get user's groups, check if member
            #
            # 2) allow for some privileged users, e.g. Security Administrator
            #    check session for the chosen privilege
            #
            # 3) many other possibilities
        }
        if ($do_unlock) {
            $entity->UnlockRecord();
        }
        else {
            $result = "You are not allowed to unlock this record.";
        }
    }
    return $result;
}

Comentarios