Skip to content

How can I automatically delete my own records that have been completed?

Answer

This can be achieved with a "Script".


Overview

This is a sample that deletes your own record if the status column is "Complete" after pressing the update button.

Operation Procedure

  1. Create a time-limited table or recorded table.
  2. Create a new "Script" and enter the contents of the script below. Check "Edit" for the output destination and update.
  3. Create a new record using the [Create New] button.
  4. Open the edit screen for the record created in 3, set the [Status Column] to "Complete", and press the [Update] button.

Code Samples

JavaScript
//Processing after pressing the "Update" button
$p.events.after_set_Update = function () {
    $p.ex.DeleteMySelfData();
}
$p.ex.DeleteMySelfData = function() {
    //Executes own-deletion when the status is "Complete".
    if ($p.getControl('Status').val() == 900) {
        $p.apiDelete({
            'id': $p.id(),
            'done': function () {
                $p.clearMessage();
                $p.setMessage('#Message', JSON.stringify({
                    Css: 'alert-success',
                    Text: 'The status is now [Completed] so the record has been deleted'
                }));
            },
            'fail': function () {
                console.log('Failed to delete record');
            }
        });
    }
}