How to delete data from related tables when deleting a data item?

shiz
Tera Contributor

1. I have an actual time table. name: u_actuant_time 2.The second table is actual time weekly. name:u_actual_time_weekly 3.The related fields of the two tables are the release_date field (which refers to the release date of actual time weekly based on the release date of actual time) 4.When I want to delete data from the actual time table now, I also want to delete the relevant data from the actual time week table. And when deleting, send a message agreeing to delete all related records. How can it be achieved?

shiz_0-1731461475695.pngshiz_1-1731461481541.png

 

2 ACCEPTED SOLUTIONS

aizawaken
Tera Guru

Hi@shiz ,


In Advance tab, you can write a script of deleting relative records in relative table, and what you want do can be achieved.

This means that you have to write a script by your self,,,

And please refer this page, and I hope it would help you.

 

View solution in original post

aizawaken
Tera Guru

Hi @shiz ,
Sorry, I have short time now,,, so let me point out 1 thing as below:

 

aizawaken_0-1731481430362.png


current.sys_id is the ID field of the u_actual_time_weekly table.
so, you should check with date value in the record. Could you check this point?

View solution in original post

4 REPLIES 4

aizawaken
Tera Guru

Hi@shiz ,


In Advance tab, you can write a script of deleting relative records in relative table, and what you want do can be achieved.

This means that you have to write a script by your self,,,

And please refer this page, and I hope it would help you.

 

shiz
Tera Contributor

@aizawaken hello

Based on that Page, I have written the following script. But  'actual time' table and 'actual time weekly' table are only one associated field is Week starts On . And I want to use ‘Week starts On’  and 'assignee_to' to  delete  'actual time weekly'.

Is the following writing correct? Where do I need to modify it?

shiz_0-1731476129591.png

 

shiz
Tera Contributor

@aizawaken dears,

shiz_0-1731477302661.png

After executing the operation:

shiz_1-1731477507857.png

Click delete button after:

Actual time of data is delete,but actual time weekly is not delete

shiz_2-1731477552367.png

actual time weekly data:

shiz_3-1731477624396.png

What's going on here?

 

aizawaken
Tera Guru

Hi @shiz ,
Sorry, I have short time now,,, so let me point out 1 thing as below:

 

aizawaken_0-1731481430362.png


current.sys_id is the ID field of the u_actual_time_weekly table.
so, you should check with date value in the record. Could you check this point?