Create delete actions in D365FO Explained
The Delete Action part helps maintain info consistency once a record is deleted. outline delete actions to specify what ought to occur once information being deleted within the current table is said to information in another table.
- Have a delete action on each relation between 2 tables. ·
- Use table delete actions rather than writing code to specify whether or not deletes area unit restricted or cascaded.
Cascade:
- A cascading deletion action can delete all records within the connected table ·
- whereas deleting a record, initial information|the info|the information} within the connected table is deleted then data within the Current table is deleted.
Restricted:
While deleting a record, if the record having any transactions then a warning message can seem. If the record isn't having any transactions in another table then solely deleted. ·
A restricted delete action can raise a slip message if the user tries to delete a record, wherever records exist within the connected table wherever the foreign key's resembling the first key of this table.
Create delete action
Cascade delete action :
create two tables
1. SchOrganisation
2. SchEmployee
create a Delete action on parent table SchOrganisation with delete Action Property “CASCADE”
parent table ( SchOrganisation) . Set a delete action property to “CASCADE” for SchEmployee. Then go and delete the record from a SchOrganisation. It will also delete all the related records in SchEmployee table automatically
Here am deleting the record SchDepartment(IT) Sch EmployeeId(503) from Parent Table i.e SchOrganisation
Data will be deleted in both tables
SchOrganisation Table:
SchEmployee Table :
Data after deletion in Above two tables :
SchOrganisation Table:
Restricted delete action
create Delete action on parent table SchOrganisation for SchEmployee table with delete Action Property “RESTRICTED”
SchEmployee Table :
parent table (SchOrganisation) . set a delete action property to “RESTRICTED” for SchEmployee table. Then go and delete the record from a SchEmployee. It will first check the record in the child table and if exist that warning prompt saying that first we need to delete a record from child table.
Example : delete record SchEmployeeId(403) from SchOrganisation.
It Will throws Error
delete the same record “SchEmployeeId(403)” which I tried to delete before from SchOrganisation table,But this time am deleting that record from child table i.e SchEmployee table.
Done record deleted successfully.
But record still exists in Parent Table i.e SchOrganisation.
Now delete that record from parent table, record will be deleted without throwing any error