Creator Help

Lock a Record when it is getting edited

With Deluge Scripting you can lock a record that is being edited and and restrict more than one user from editing the same record at the same time. Sample Application - Database Locking illustrates the same.

  • Create a Form, for example, with name “LockedID” with a number field to store the ID number of the record being edited in ‘Form X”.
  • In the On edit ->on load section of “Form X”, add script as shown in the format below.
if ( (LockedID[Number_Field == input.ID].count() == 1) ) 
{
hide Email_ID;
hide Name;
plain = "This record is in use. Please try after sometime";
}
else
{
insert into LockedID
[
Added_User = zoho.loginuser
Number_Field = input.ID
]
}

The script checks if a record with the current ID exists in LockedID form. If exists, hide all the fields in the form and display the message that the record is in use, if not, the record ID will be added to the LockedID form.

Here, plain field refers to a “Add Notes” field type to display the required message.

  • In the on edit ->on success of “Form X”, add script as shown in the format below, to delete the record from LockedID form.
delete from LockedID[ Number_Field == input.ID ];

Note

  • Please note that the on edit ->on success script will be executed only when the record is updated on click on the “Update” button. If the user, clicks on “Cancel” or “Close” button of the Edit dialog, the script will not be executed and hence the recordID which is locked will not be deleted.
  • A work around for the above limitation is to run a custom schedule periodically on the LockedID form that will compare the Added_Time of the records with the current time and delete entries that are listed form than a specific period, say 5 to 10 min.

Top