Yes, with Deluge Scripting you can lock a record that is being edited as described in the steps given below:
1. 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".
2. In the on edit -> on load success of "Form X", add script as shown in the format below.
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, input.plain field refers to a "Add Notes" field type to display the required message.
Copy code
- if (count(LockedID[Number_Field == input.ID]) == 1)
- {
- hide Email_ID;
- hide Name;
- input.plain = "This record is in use. Please try after sometime";
- }
- else
- {
- insert into LockedID
- [
- Added_User = zoho.loginuser
- Number_Field = input.ID
- ]
- }
3. In the
on edit -> on success of "Form X", add script as shown in the format below, to delete the record from LockedID form.
Copy code
- 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.