LockRecord

Description

Creates a lock on the record.

Acquiring a record lock includes the ability to specify a maximum wait time in seconds. This value is the time to wait for an existing lock to be released before the lock attempt fails. The lock attempt fails if the lock cannot be acquired before the value specified by the wait_seconds parameter has elapsed.

The method throws an exception if the lock cannot be acquired for any of the following reasons:
  • Feature Level is less than FL7.
  • The record type is system owned.
  • The record is locked by another user.
  • The record is locked by another session.
  • The record was updated during lock.
To enable record locking, for each record type:
  • Add a new action named LockRecord of type BASE.
  • Add an Action_Initialization hook to the action, and have the hook call the LockRecord method. Par exemple,
    $entity->LockRecord(0);
Remarque : Cette méthode est disponible dans la version 7.1.

Syntaxe

VBScript

entity.LockRecord wait_seconds 

Perl

$entity->LockRecord(wait_seconds); 
Identificateur
Description
entity
Objet Entity représentant un enregistrement de données utilisateur. Si vous omettez cette partie de la syntaxe au sein d'un point d'ancrage, l'objet Entity correspondant à l'enregistrement de données en cours est faux (VBScript uniquement).
wait_seconds
A Long that specifies the number of seconds to wait for an existing lock to be released before the lock attempt fails.
Valeur de retour
Aucune.

Exemples

VBScript

Function Defect_LockRecord(param)
' Lock Record for RECORD_SCRIPT_ALIAS action
  ' param As Variant
  ' le nom tu type d'enregistrement est Defect
    REM add your hook code here
  ' don't wait
    LockRecord(0) 
End Function


Sub Defect_Initialization(actionname, actiontype)
' Lock Record for BASE action Action_Initialization hook
  ' actionname As String
  ' actiontype As Long
  ' action is LockRecord
  ' le nom tu type d'enregistrement est Defect
    REM do any setup for the action here
    LockRecord(0)
End Sub

Perl

sub Defect_LockRecord {
 # Lock Record Script for RECORD_SCRIPT_ALIAS action
 my($result);
 my($param) = @_;
 # le nom du type d'enregistrement est Défaut

 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");
       }
 # don't wait
   $entity->LockRecord(0);   
  return $result;
 }


sub Defect_Initialization {
 # Lock Record script for BASE action Action_Initialization hook
    my($actionname, $actiontype) = @_;
    # $actionname : scalaire de chaîne
    # $actiontype : scalaire long
    # l'action est Verrouiller l'enregistrement
    # le nom du type d'enregistrement est Défaut
    # C'est ici que se configure l'action.
      $entity->LockRecord(0);
}

Commentaires