0

do a record mod whilst runnings an Api script

whist running the below script . I would like to modify a yes/no field in the table records after it deletes the files for each record. ie 'ImagesDeleted' := 2'.

I tried put this in various places but can't get it to work. within the DPI whist it is dleeting the files.

I tried like (in this extract) - just a pure guess on my part as  never modified an Api call before

   let rid := text(i);

let myDel := number(i)

        while cnt(files(i)) != 0 do 
            let file := urlEncode(text(i.Filename));
            let url := ---
https://api.ninox.com/v1/teams/{ teamid }/databases/{ dbid }/tables/{ tid }/records/{ rid }/files/{ file } records/{myDel}

Of course the above does not work but How do i do it  within an API script?

 

full script is below

let mySure := dialog("Sure?", "Are you Sure?", ["Yes", "No"]);
if mySure = "Yes" then
    let method := "DELETE";
    let teamid := teamId();
    let dbid := databaseId();
    let tid := "B";
    let cont := "application/json";
    let bear := "Bearer " + first(select Settings).'API-Key';
    for i in select JobDockets where 'Order Date' <= today() - 180 and Status = 4 do
        let rid := text(i);
        while cnt(files(i)) != 0 do 
            let file := urlEncode(text(i.Filename));
            let url := ---
https://api.ninox.com/v1/teams/{ teamid }/databases/{ dbid }/tables/{ tid }/records/{ rid }/files/{ file }
                ---;
            let response := do as server
                    http(method, url, {
                        Authorization: bear,
                        'Content-Type': cont
                    }, {})
                end;
            if response.error then
                alert(text(response.error))
            end
        end
    end
else
    alert("Okay - Nothing has been deleted")
end

1 reply

null
    • Ninox partner
    • RoSoft_Steven.1
    • 5 mths ago
    • Reported - view

    I guess you could put this here: (by adding both yellow lines)

    {prev. code}
    .....

             if response.error then
                    alert(text(response.error))
                end
            end
    ;
    i.(ImagesDelete := 2)

        end
    else
        alert("Okay - Nothing has been deleted")
    end

Content aside

  • 5 mths agoLast active
  • 1Replies
  • 36Views
  • 2 Following