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

null
    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    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

    • Ninox developper
    • Jacques_TUR
    • 1 yr ago
    • Reported - view

    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);
          }
        ); }#
    
      • CISOFT_Sarl
      • 6 mths ago
      • Reported - view

       Hello i hope you are fine. Can you explain the syntax of your code with #{:text:callback
      Whats append # and where find the usage of this. Have a nice day. Robert

      • Ninox developper
      • Jacques_TUR
      • 6 mths ago
      • Reported - view

       

      Hello Robert, the notation :callback indicates to Ninext that this is an asynchronous function (see the async function in JavaScript) that will return its value by in turn calling a function named callback(). The rest of the Ninox code will only be executed after this function has been called. It's somewhat like when we use "await" with a Promise function.

    • Alan_Cooke
    • 1 yr ago
    • Reported - view

    Thank you Jacques - first class as usual

Content aside

  • 6 mths agoLast active
  • 5Replies
  • 310Views
  • 4 Following