Multiupload - No deletion of uploaded files question?

I have a requirement for document uploads that they cannot be deleted whatsoever. Server disk space is not an issue, i want to keep every file and every database entry of all uploads.

I setup the upload, file location and database table. All works fine no problems. However there is a “delete” option next to every file that gets uploaded.
I have no idea how to get rid of this. I have contacted support, they just say there is no way to modify the structure of the Scriptcase upload feature.
That sounds silly to me as it was created in the first place, there must be some way to remove it or at least hide it from users.

Anyway i was hoping one of you guys have already come across a way to do this, and could give a couple pointers at what i should do if it is possible.

The fields i am talking about are shown in the attached image.

Thanks very much in advance

Mike

remove delete option.jpg

Options: in your code set the file as readonly
Options: add some javascript to hide the delete button, you could use the hide javascript function.
Options: add some code on the OnBeforeDelete that gives an actual sc_error_message

Thanks for Reply!

[QUOTE=rr;23427]Options: in your code set the file as readonly
Options: add some javascript to hide the delete button, you could use the hide javascript function.
Options: add some code on the OnBeforeDelete that gives an actual sc_error_message[/QUOTE]

Thank you very much for your reply.

Setting the Field as read only did not work, it didn’t hide the delete checkbox. However it made it seem as though no changes were made upon saving, after a refresh i find the file is deleted.

I have tried Javascript, i put this code in form onload event.

document.getElementById("id_mu_chkbx_documents"). style.visibility="hidden";

The code runs and can see code in DOM explorer. However checkbox is still visible, maybe im doing something wrong here.

For some reason the OnBeforeDelete doesn’t work with document uploads on a form for another table becuase i’m not deleting the record for the product but i am deleting a file saved to another table. However the OnBeforeUpdate does seem to. This seems like best option for now unless i get the javascript to work. However it relies on users to not hit delete, would rather not even have the option for temptation :slight_smile:

I do see the option to position the delete checkbox in the field itself to either “below” or “beside” when setting up the form field, im wondering if i could use this in the scriptcase code to add new option to hide. Hopefully they could add it to next Scriptcase 8.

Thanks again for reply, much appreciated.

Sorry i didn’t realise you meant the file and not field as read only. Scriptcase doesn’t delete the actual file anyway so this isn’t really an issue at the moment. It’s the database record that’s causing problems, as i don’t want any deletion. Finding a way to hide or remove the “delete” option is the only thing i need to do.

I’ll keep working on the Javascript way, i don’t know what i could be doing wrong though that the code doesn’t work.

I think i have found some code in the source where i can add a new option to hide, so i will have 3 options for “delete” position: “Below”, “Beside”, and new option “Hidden”. What would be better is if there was someway of adding the upload field to a security group so permissions can be set for uploading, deleting and/or editing (for editing i mean uploading an updated version of a file to either overwrite or add file version suffix to filename). Otherwise i can manually change code per app, but that is a very long process.

Hopefully Netmake will add this option to an update or Scriptcase 8, because not everyone wants all users to be able to delete but do want them to be able to upload.

Thanks for your time. :smiley:

Resolved

Resolved with Javascript

I realised i was getting the element by ID and not class which is why the script didn’t work. I used DOM explorer to find the names of classes i wanted to hide and run script in Form onload event.

Replace highlighted red class names with the class names that your app uses.

 var divsToHide = document.getElementsByClassName("id_mu_chkbx_documents");

    for(var i = 0; i < divsToHide.length; i++)
    {
    divsToHide[i].style.visibility="hidden";
    }
 var divsToHide = document.getElementsByClassName("id_mu_item_documents");

    for(var i = 0; i < divsToHide.length; i++)
    {
    divsToHide[i].style.visibility="hidden";
    }
 var divsToHide = document.getElementsByClassName("id_mu_data_documents");

    for(var i = 0; i < divsToHide.length; i++)
    {
    divsToHide[i].style.visibility="visible";
    }

EDIT: I realised the code used previously was only hiding the first rows checkbox and text. The improved code above will now remove all rows.

Using this code, i have now hidden the delete option checkbox and “Delete File” text. File uploads now only show the documents that have been uploaded. See below screenshot:

Thanks for your help RR.

uploadhidedelete.jpg

Above Code, Didn’t quite work as planned.

Above code did not work fully as intended. All the checkboxes and the “Delete File” text were hidden, However the more files that were uploaded the bigger the space at the bottom becuase the files were only hidden. That made my forms look a bit crap.

Found some other annoying problems using the up-loader and having documents displayed below.

Filenames were changed to random letters and numbers when attempting to download. Also when setting uploads to use a variable as a subfolder the files below the uploader were giving an error message about “file does not exsist”. Checkboxes were not deleting files from the server only the database entry.

So now i just remove the filename, icons and checkboxes from displaying at all using this code here:

document.getElementById("id_sc_loaded_documents").remove();

[SIZE=3]Run in ‘OnLoad’ Event[/SIZE]

As you can see below the list of documents below upload area is now gone and space below is also gone. Documents can be managed a better way through the grid viewer. The Upload list below upload area has many problems, also the list does not pick documents that have related ID but uploaded on different form, it only shows documents that have been uploaded via the form being used.

docsgone.png

Thanks for share :wink:

Thanks for that addition… Very usefull…