0

Is it possible to delete all PDF file attachments on any given record without having to delete them one at a time?

I have many files with PDF attachments that I no longer need and want to go thru my database and delete those files. What’s the best way to do this?

I thought something like this might do the trick but it doesn’t:

delete(files(this));

Any ideas?

Thanks in advance.

11 replies

null
    • Support
    • 4 yrs ago
    • Reported - view

    This is going to be possible soon.

    Birger

    • scopic
    • 4 yrs ago
    • Reported - view

    yes please !

    • Ninox
    • Bilguun_Gantulga
    • 4 yrs ago
    • Reported - view

    Hello Guys I found an alternative for this problem.

    You have to duplicate the current record, which will transfer all the data except the attachments and image fields.

    After that you have to delete your original record;

    For instance your button code will look like:

    let new := duplicate (this);

    delete this;

    openRecord(new) 

    • Ninox
    • Bilguun_Gantulga
    • 4 yrs ago
    • Reported - view

    P.S. Be careful with this one! It might not transfer everything!

    • Mel_Charles
    • 4 yrs ago
    • Reported - view

    NINOX - yes please

    I have a table with over 10,000 records on it and i want to delete all the attachments on records on a set date that are over x years old to free up disk room but without resorting to deleting the records themselves.

    A feature to delete them in bulk would really be great. Really don't fancy editing/deleting them one at a time when the time comes!!

    • Ninox developper
    • Jacques_TUR
    • 3 yrs ago
    • Reported - view

    This code maybe help you. It delete all files for one record :

    let NumId := this.ID; 
    let i := 0;
    let FileName := “”;
    for f in files(this) do
    FileName := text(f);
    FileName := substr(FF, index(FF, “/”) + 1);
    let lien := “https://api.ninoxdb.de/v1/teams/” + teamId() + “/databases/” + databaseId() + “/tables/” + tableId(“Sessions”) + “/records/” + NumId + “/files/” + FF;
    alert(“Suppression du fichier :” + FileName);
    let response := http(“DELETE”, lien, {
    Authorization: “Bearer ***YOUR API NUMBER***”,
    “Content-Type”: “application/json”
    }, null);
    void
    end 

    • Ninox developper
    • Jacques_TUR
    • 3 yrs ago
    • Reported - view

    Oops, on this line, you must put your table name (Sessions is my table“s name😊)

    let lien := “https://api.ninoxdb.de/v1/teams/” + teamId() + “/databases/” + databaseId() + “/tables/” + tableId(”***YOUR TABLE NAME***“) + “/records/” + NumId + “/files/” + FF;

    • Ninox developper
    • Jacques_TUR
    • 3 yrs ago
    • Reported - view

    Oops, I made a mistake when I reformatted the code for you. This code works now.

    let NumId := this.ID; <- PUT YOUR RECORD ID HERE
    let i := 0;
    let FileName := “”;
    for f in files(this) do
      FileName := text(f);
      FileName := substr(FileName, index(FileName, “/”) + 1);
      let lien := “https://api.ninoxdb.de/v1/teams/” + teamId() + “/databases/” + databaseId() + “/tables/” + tableId(“YOU TABKLE NAME”) + “/records/” + NumId + “/files/” + FileName;
      alert(“Suppression du fichier :” + FileName);
      let response := http(“DELETE”, lien, {
    Authorization: “Bearer YOUR API CODE”,
    “Content-Type”: “application/json”
    }, null);
    void
    end
     

      • Mconneen
      • 1 yr ago
      • Reported - view

      Jacques TUR .. Just to be clear.. that works only for Ninox Hosted workspaces / databases.. You need another strategy if a local / iCloud database.

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

      Mconneen Yes, with local applications, the only one I know is to use JavaScript.

    • Mconneen
    • 1 yr ago
    • Reported - view

    Thanks.. I am having some issues getting the JS to work.. but will plug through it.

Content aside

  • 1 yr agoLast active
  • 11Replies
  • 1445Views
  • 3 Following