I am in the process of setting up a document upload as part of a form submission but once this has been completed and the email sent I would like to completely delete the assets that were uploaded. These documents will contain sensitive data and can’t hang around the CMS for longer than they need to, so if possible removed from the trash as well.
I have followed the batching example on the manuals site but when it gets to the bit about supplying the asset ids to the trashAssets it errors out with:
Exception occurred when executing JS API function “trashAsset()”: Assertion failed: [NULL] “” is not a valid asset ID
Where am I going wrong? Ideally, I would like to be able to supply an array of all the file ids found in the folder but I can’t work that bit out either.
Also, I would like to run this after the form has been submitted, how should I go about this? Should I use a trigger or a form submission action to achieve this? Also, how do I access the JS API I created for this task then run the code above?
Not without manually purging the trash. But you could potentially overwrite the sensitive data with dummy data with a separate JS API call if that would help?
If you simply want to trash the form submission asset after it has been completed, you should just use a trigger and use the form submission completed event. Would that work?