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¶
- Create a time-limited table or recorded table.
- Create a new "Script" and enter the contents of the script below. Check "Edit" for the output destination and update.
- Create a new record using the [Create New] button.
- 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');
}
});
}
}