4D v16.3

Get locked records info

Home

 
4D v16.3
Get locked records info

Get locked records info 


 

Get locked records info ( aTable ) -> Function result 
Parameter Type   Description
aTable  Table in Table where you want to get locked records
Function result  Object in Description of locked records (if any)

The Get locked records info command returns an object containing different information about the currently locked record(s) in aTable.

The returned object contains a "records" property which is an array of objects:

{
    "records": [
        description object,
        (…)
    ]
}

Each "description object" array element identifies a locked record in the specified table and has the following properties:

PropertyTypeDescription
contextIDUUID (String)UUID of the database context responsible for the lock
contextAttributesObjectObject containing information similar to the LOCKED BY command but applied to the record, the difference being that Get locked records info returns the user name defined in the system and not that of the 4D user, as well as additional information (see below).
recordNumberLongintRecord number of the locked record

The contextAttributes object is made up of the following properties:

PropertyTypeDescription
task_idNumberProcess reference number
user_nameStringUser name defined by operating system
user4d_idNumber4D user number(*)
host_nameStringName of host machine
task_nameStringProcess name
client_versionNumberVersion of client application
Only when command is executed on 4D Server and if record locking comes from a remote 4D:
is_remote_contextBooleanIndicates whether a remote 4D is the origin of the locking(always true since otherwise it is not present)
client_uidUUID (String)UUID of 4D remote at the origin of the locking

(*) You can get the 4D user name from the value of user4d_id by using the following code:

 GET USER LIST($arrNames;$arrIDs)
 $User4DName:=Find in array($arrIDs;user4d_id)

Note: The command works only with 4D and 4D Server. It always return an invalid object when called from 4D Remote or a component. However, it can be called in these contexts if the "Execute on server" option is activated. In this case, the object returned will contain, respectively, information about the server or the host database.

Example  

You execute the following code:

 $vOlocked :=Get locked records info([Table])

If two records were locked in the [Table] table, the following object is returned in $vOlocked:

{
    "records": [
        {
            "contextID": "A9BB84C0E57349E089FA44E04C0F2F25",
            "contextAttributes": {
                "task_id": 8,
                "user_name": "roland",
                "user4d_id": 1,
                "host_name": "iMac de roland",
                "task_name": "P_RandomLock",
                "client_version": -1342106592
            },
            "recordNumber": 1
        },
        {
            "contextID": "8916338D1B8A4D86B857D92F593CCAC3",
            "contextAttributes": {
                "task_id": 9,
                "user_name": "roland",
                "user4d_id": 1,
                "host_name": "iMac de roland",
                "task_name": "P_RandomLock",
                "client_version": -1342106592
            },
            "recordNumber": 2
        }
    ]
}

If the code is executed on a 4D Server and the locking is caused by a remote client machine, the following object is returned in $vOlocked:

{
    "records": [
        {
            "contextID": "B0EC087DC2FA704496C0EA15DC011D1C",
            "contextAttributes": {
                "task_id": 2,
                "user_name": "achim",
                "user4d_id": 1,
                "host_name": "achim-pcwin",
                "task_name": "P_RandomLock",
                "is_remote_context": true,
                "client_uid": "0696E66F6CD731468E6XXX581A87554A",
                "client_version": -268364752
            },
            "recordNumber": 1
        }
    ]
}



See also 

Locked

 
PROPERTIES 

Product: 4D
Theme: Record Locking
Number: 1316

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v14 R3

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)