1 (edited by g0dmenuelz 2019-05-19 14:06:57)

Topic: How come I can't delete a data on the record?

Hi guys, I  have a weird issue here. How come I can't delete any data on the records.
It seems it is locked or something is preventing me from deleting it.
Is it because of some of the scripts?

Kindly take a look. Thanks

Post's attachments

Attachment icon Test.rar 1.06 mb, 265 downloads since 2019-05-19 

2 (edited by k245 2019-05-19 15:35:48)

Re: How come I can't delete a data on the record?

Deletion is blocked because there is a link (foreign key) in the dochistory table to the docmaster table. You must allow cascade delete.

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=5468&download=0

Post's attachments

Attachment icon FK3.jpg 169.41 kb, 142 downloads since 2019-05-19 

Визуальное программирование: блог и телеграм-канал.

Re: How come I can't delete a data on the record?

Hello k245, Thanks for the help
But it's really weird cause I tried cascade delete on docmaster on dochistory the same way you did and it is still giving me an error.

Re: How come I can't delete a data on the record?

Hi,
If you have no success with cascade delete (which is the usual way to do it), then you can manually delete the document history records first and then the document master - see the attached amendment to your program when you click 'delete'. 
Obviously, the whole thing could be automated but I'm not sure it's a good thing to make it too easy for deletions.
If it were me, rather than physically delete a record (and lose the audit trail), I'd use a 'deleted' status (just like all your other statuses - received, printed, filed etc etc).  So select a 'deleted' status and it gets automatically added to the 'document history' with a date/time stamp.  You could then filter out your 'deleted' documents if you don't want your users to see them on Form1, but they'd still be held in the DB for audit purposes.
The other thing you'd need to consider are any attachments you might be holding in a 'copy to' folder (if I remember correctly, it's something you were asking about earlier).  If you were physically deleting the document master and document history, it will be leaving 'orphaned' documents in your 'copy to' folder so you'd either need to manually clear those out or delete them by script.
Derek.

Post's attachments

Attachment icon Test.zip 1.11 mb, 249 downloads since 2019-05-19 

5 (edited by k245 2019-05-19 17:10:59)

Re: How come I can't delete a data on the record?

g0dmenuelz wrote:

Hello k245, Thanks for the help
But it's really weird cause I tried cascade delete on docmaster on dochistory the same way you did and it is still giving me an error.

I check - records deleted. But I totally agree with Derek - use to delete the status change.

Post's attachments

Attachment icon TEST.zip 1.11 mb, 277 downloads since 2019-05-19 

Визуальное программирование: блог и телеграм-канал.

Re: How come I can't delete a data on the record?

Thanks again guys. I learn new things everyday. smile