UnlockRecord

설명

레코드에서 잠금을 해제합니다. 잠금을 소유하고 있는 사용자, 수퍼유저 권한이 있는 사용자 또는 스키마 디자이너 권한이 부여된 사용자만 잠금을 제거할 수 있습니다. 다른 사람 또는 다른 세션에서 레코드를 잠갔거나 레코드가 업데이트된 경우 예외가 발생됩니다.

조치를 확약하거나 되돌리면 레코드 잠금이 자동으로 해제됩니다. RECORD_SCRIPT_ALIAS 후크를 사용하여 사용되지 않는 잠금을 수동으로 제거할 수 있습니다.

각 레코드 유형에 대해 수동으로 레코드 잠금을 해제하려면 다음을 수행하십시오.
  • 이름이 Unlock인 새 레코드 스크립트를 작성하십시오.
  • 유형이 RECORD_SCRIPT_ALIAS이고 이름이 Unlock인 새 조치를 추가하십시오.
  • 레코드 스크립트 조치를 Unlock 스크립트로 설정하십시오.
주: 이 메소드는 버전 7.1부터 사용 가능합니다.

구문

VBScript

entity.UnlockRecord  

Perl

$entity->UnlockRecord(); 
ID
설명
entity
사용자 데이터 레코드를 나타내는 Entity 오브젝트. 후크 내에서 구문에 이 부분을 생략할 경우, Entity 오브젝트가 현재 데이터 레코드에 해당한다고 가정합니다(VBScript에만 해당).
Return value
없음

예제

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;
}

피드백