Cancel deleting a record


This article introduces how to cancel deleting a record while in the Delete Submit Event.
For example, when a user deletes a record, this deletion can be cancelled if fields in the App do not mach a given condition. A custom error dialog will also appear when the deletion is canceled.


The two events that support cancellation of record deletions are the following:


Prepare the App

In this article, we will add this customization to the Document Library App that can be found on the kintone Marketplace. After creating the Document Library, the below field is added to the form:

Field Type

Field Name

Field Code


Check box

Allow deletion


Add one check box option with the label "Yes".



After adding this field, save and update your App.
Also proceed to create a new record in the App.

Sample Code

Canceling the deletion of a record can be achieved for the record.detail.delete.submit event and the record.index.delete.submit event by following one of the three processes below in the event handler:

  1. By returning false
  2. By inserting a message into event.error, and returning the event object
  3. By returning the thenable object using resolve(false), or by using resolve(event) after setting a message in event.error

In this sample, we will use the second option, where we place a message into event.error.

Test the Code

Upload the JavaScript file to the App, and open up a details page of a record. Make sure the "Allow deletion" field is unchecked, and try deleting the record.



If the code is successful, an error message will appear on the screen, and the record will not be deleted.



Next, check the "Allow deletion" check box and save the record. Proceed to Delete the record.




The record should delete successfully.



Preventing users from deleting records can actually be achieved without JavaScript, by using kintone's Record Permission features. This sample customization though allows you to display an error message to the users of the App, to explain about the next action they should be taking - this is something that cannot be done with kintone's basic features alone.

Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!