Determine if a delete was performed in a CI that should have been a cascade delete
If you are having trouble with deleted items in a CI, check to see if a delete was performed that should have been a cascade delete.
If you go to a record and receive an error message, it is likely that the deleted record is without a cascade. The error message might say something like: Warning! Deleting this record will result in the automatic deletion of the following related records: 1 Asset. Note that the related records may trigger their own cascade deletions. Proceed?
Determine what other tables reference the deleted record by using Related Lists. Look at the dictionary entry for the corresponding reference field and check to see what Reference cascade rule is set. If the Reference cascade rule is set to Delete and the user tries to delete the corresponding referenced record, the platform should always give a warning message, such as the one mentioned above. If no warning comes up, then this rule was probably set to the default value.It is important to understand how referenced fields should behave on a CI. The platform provides different options for how the deletion affects records that reference the deleted record. The three cascade delete rule options for each reference field are:
- Clear the reference. This is the default action and means that the reference field will be cleared if their associated referenced record is deleted.
- Delete the reference. This is more drastic, wherein the record itself will get deleted when its corresponding referenced record gets deleted.
- Restrict the delete. This will prevent the referenced record from being deleted at all if any other record includes a reference to it.
To set the Reference cascade rule for a field, personalize the dictionary for the field and populate one of the following choices in the Reference cascade rule field:
- Clear: Deleting a record clears references as described above. This is the default action.
- Delete: Deleting a record also deletes all referencing records.
- Restrict: Deleting a record is restricted unless there are no references to the record.
You can restore inadvertently deleted records and audited references to the records. The restoration process also restores records that were deleted as a result of a cascade delete action. For more information, please see Restoring Deleted Records in the ServiceNow product documentation.