0

Infinite process when getting attachment in a form through a table linked through a another table

Hello,

I got a table C (actually just to display this form). This has a form. This form shows content of table B.

In this form there is a radio button (it also doesn't work as a select). When pressing this radio button it loops all content of table B. Table B is linked with table A. The loop is getting the attachment of table A through table B. And this is where nothing happens and the process runs infinite.

I check the background processes and it runs forever and also slows down the system.

I made myself a multiline text for debugging purposes and went through the entire code. And found that the attachment is the problem. When the problem occurs, don't even the very first line "History := 'Start'" doesn't get executed.

My code is like this:

let b := select tableB where active = true
for item in b
    let att1 := first(files(item.files.tableA));
    let att2 := last(files(item.files.tableA));

 

Why am I doing this like that? I want to automate a process through make. This needs to run once a day. The trick I am doing here:
- creating a new entry in table C
- set the radio button
- radio button on change: run this code

I already automate this way another process which runs once a day. That another one runs fine, but the other one doesn't have attachments.

4 Antworten

null
    • Leonid_Semik.2
    • vor 2 Jahren
    • Gemeldet - anzeigen

    Hello Thomas,
    Ninox cannot move files between two tables or between two records.

    to copy a file you can use the following code:
     

    let shareLink:=shareFile(nid1,fileName);
    importFile(nid2,shareLink,fileName).


    To delete a file by script you need an API call. Here is the example:
     

    curl
    https://api.ninox.com/v1/teams/XXXXXXXXX/databases/YYYYYYYYYYY/tables/A/records/10/files/iStock-184877012.jpeg
    -X DELETE
    -H 'Authorization: Bearer c0da1580-1a26-11ec-ba4d-f9d8817e4f95'
    -H 'Content-Type: application/json',


    If you use MAKE for automation then you can also automate everything with MAKE-Ninox modules Download File from Record, Delete File From Record and UploadFile To A Record.

    Leo

      • Thomas.9
      • vor 2 Jahren
      • Gemeldet - anzeigen

      Leonid Semik hayhay. I am coming back to copying files for another use case I have. But I can't get it working.

      I have this code:

                  shareLink := shareFile(this.Nr, fileName);
                  debug := "id: " + this.Nr + "
      fileName: " + fileName + "
      shareLink: " + shareLink + "
      shareFile: " + shareFile(this.Nr, fileName) + "
      -
      " + debug;
      

      I use a multiline texfield as debug and print there stuff.

      I get an nid. I get an fileName. But the shareLink and shareFile variable are empty and the functions do nothing.

      Also, of course, the follow up code, which imports the file in another record, does not import the file in another record.

      • Thomas.9
      • vor 2 Jahren
      • Gemeldet - anzeigen

      Thomas the problem was that fileName still had something before the path. U can rid of it like that:

      fileName := item(split(text(item), "/"), 1);
      
    • Thomas.9
    • vor 2 Jahren
    • Gemeldet - anzeigen

    Aw geez, looks like it was all an syntax error on another part. I fixed other things in my script and now it works. I was also wondering when reading you're reply, that I don't copy anything.

    Thanks for your help though!

Content aside

  • Status Answered
  • vor 2 JahrenZuletzt aktiv
  • 4Antworten
  • 105Ansichten
  • 2 Folge bereits