0
Is there a 'command' to delete an attachment?
I want to have a button that can delete a file attachment (paper clip). Does it exists? I am aware that this might not be possible given there could be more than one attachment but worth asking anyway.
5 replies
-
You can use API to delete a file :
https://docs.ninox.com/en/api/public-cloud-apis#delete-a-single-file
You can also do it with JavaScript on HTML or NativeJS :
var file := first(files(this)); // or other file name like "A1/file.pdf"; #{:text:callback var [tableId, recId, fileName] = util.parseNIDFile( file); database.removeFile( tableId + recId, fileName, function (error) { $.loading(!1) if (error) callback( error ); else callback(fileName); } ); }#
return deleted file name or error message if failed
-
You can also rename a file with similar NativeJS code :
var file := file(this, "myFileName.pdf"); "// put here your old file name"; var newFileName := "myNewFileName.pdf"; "// put here you new file name"; #{:text:callback // retrieve all information from the record in the complete file name var [tableId, recId, oldFileName] = util.parseNIDFile( file); /* call rename file function of Ninox with record ID (tableID + Rec ID), old and new file name, and the return function which indicates if the operation was successful or not*/ database.renameFile( tableId + recId, oldFileName, newFileName, function (error) { /* call the callback function to execute the rest of the function code with the return value*/ if (error) callback( error ); else callback(newFileName); } ); }#
-
Thank you Jacques - first class as usual
Content aside
- 1 yr agoLast active
- 5Replies
- 376Views
-
4
Following