Delete Files added to paper clip
I have an archive that I want to BULK delete various images attached to records. I want to keep the records but no longer need the images that are attached to them.
Where the files have been in a custom Images in records. It has been easy to overwrite to null from a button script.
ie
let mySure := dialog("Sure?", "Are you Sure?", ["Yes", "No"]);
if mySure = "Yes" then
for a in select JobDockets where Status = 4 or Status = 7 do
a.(SupplierQuote := null);
a.(SupplierConfirmation := null);
alert("Records have been deleted from the system")
end
else
alert("Okay - Nothing has been deleted")
end
All images for the last year or so have been stored this way as it gives me control to delete them in bulk.
However my issues is that for the first few years files were attached the the paperclip as back then I did not realise that it would not be easy to delete them in bulk. There is bulk edit facility to get at the paperclip and the above script work for these. (of actually I have not found a way to access the paperclip). I have about 3500 images I want to delete over some 2000 records and this could take me forever by hand.
So I am hoping that someone has successfully produced a script for deleting paperclip attachments? If so, could you possibly consider sharing how you achieved this ?
21 replies
-
After the deletion of your image fields with Image := null. Did you have a look at the attachments tab?
-
File deletion in attachments tab can be done with the Ninox API
-
Works perfect. First time I use API for something.
-
Thats great thank you, your sample makes sense to me.
I have not touched anything relating to API before so very much learning this as of now.
so i have keying into my live database your coding and setups the fields as per your example.
Before I run this - I want to take several backups when other users are out.
re your question about flushing other image fields to null - I was aware that it would populate back into the clipboard attachments . hence the reason the find a way to clear these. Interestingly in my few tests and a a dozen or so sample images - not all appear go back to the clipboards so i wander if some are left orphaned on Ninox server
Your script will delete all attachments and that is fine for me as onece gone I will turn off the attachments as far as users are concerned and then any image files set to Null from a script will populate in the background clip and I can then run your script from time to time.
what is "bearer " significance it appears to be text ?
and is the api key specific to just each database - so if i restored a copy of database that database would have the same key in it. If I ran your script code in that copy would it impact on database A in error?
whole new area for me to get to grips with...
-
That is fantastic my friend !!!
I can make great use of both the per record basis and global for the table - !!
re the question of per record.
just checking did you design it like this example
There are 3 attachments on paperclip - I press the buttton and the first is deleted and the other 2 shuffle forward - I press the button again and the now new first file is deleted etc i do this untill all files are deleted for that one record!.
Do you think it is possible to modify the script so at all attachments for that one records are deleted on the one button press?
-
I couldn't wait until tonight
so in the copy of my live DB with the test table
There we 370 with either 1, 2 or 3 or images in them. Total image count was around 580 - however the table records itself number some 9700 records with 9120 records with NO images in.
Thus the report to clear all images in all records still has to check those records with 0 images in - in order to discount them. I thinks the call to do this either was hanging due to memory issue or making the server at Ninox end hang/fall over OR maybe was simply gonna take hours even at the server end!
Done further test in sofar as deleting all but some 300 records and all 3 scripts do indeed work in my play copy. !
So I guess - I might need to look at running this on a batch of records at a time.
I will have a go a compiling a header part of your script to select a batch of records in order say 400 at a time. I'm thinking of something along the lines of bolting something like this in.
let a := (select JobDockets where 'Status = 7 );
for myVar in slice(a, 0, 400) dobut not thought it through yet ....
-
RoSoft_Steven Just I case I didn't make it clear or forgot to say so. Steven you are a complete star! The solutions issued by you is breathtakingly superb! - This will make my life so much easier - Once I get around to sorting in batches but thats my problem.
I have quite a bit of interaction with Ninox support over images and I will out my findings on a separate topic.
Content aside
- 1 yr agoLast active
- 21Replies
- 293Views
-
3
Following