KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to programmatically delete a locked document
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: May 22, 2002

Compatibility: 6.5.x, 6.7.x, and 6.8.x

This tech tip explains how you can delete a file whose access rights are set to Read only. If you execute the command DELETE DOCUMENT to this file, you will get a permission error. If you are certain that you want the document to be deleted, you can avoid this problem by first checking the document permission with the command GET DOCUMENT PROPERTIES. If the document is locked (Read only), you will execute the command SET DOCUMENT PROPERTIES to set the permission of the document to read/write.



Here is an example:



C_BOOLEAN($Locked;$inv)

C_DATE($createdon;$modon)

C_TIME($createdat;$modat)

GET DOCUMENT PROPERTIES($targetfile;$Locked;$inv;$createdon;$createdat;$modon;$modat)

If ($Locked)

SET DOCUMENT PROPERTIES($targetfile;False;$inv;$createdon;$createdat;$modon;$modat)

End if

DELETE DOCUMENT($targetfile)