0

When to use "do as server"?

I've been using "do as server" code in lots of my buttons just to make my forms a bit snappier. Unfortunately I've found that on an older/slower computer for some reason the code isn't executed properly.

The specific problem I'm having is that one of the things the button is supposed to do is create a new record on a different table. With the "do as server" code there it only creates a new record sometimes.

I've looked through the forum and found other people running into issues with this code. Are there ways to properly use "do as server"?

10 replies

null
    • Alex_Mumm
    • 1 yr ago
    • Reported - view

    I should mention that I'm using the web app.

    • Alex_Mumm
    • 1 yr ago
    • Reported - view

    On closer inspection, one of my buttons doesn't have "do as server" code, but is still failing to create the new record in Bulk Inventory. Again, this problem is only happening on one (old) computer so far.

    • Paul_Chappell
    • 1 yr ago
    • Reported - view

    Just a guess but line 1 shows 2 fields. They look like a date/time field and a number (or maybe yes/no) field. In which case you are not resolving either field. As in if ‘Date/time Draining’=date value and ‘Draining? NV’= value then …  Without resolving both fields the rest of the script won’t fire.

    • Mel_Charles
    • 1 yr ago
    • Reported - view

    do as server - is a request to get ninox to do the processing on the server side before passing results back to the client side which saves on back and forth activity thus any processing is done quicker. That command has no bearing on creating the new record.

      • Alex_Mumm
      • 1 yr ago
      • Reported - view

      Mel Charles You might be right about that, but it does definitely give me unexpected results elsewhere. For example, if I look up the Id of the last record in a table and then create a new record and then look up the Id of the last record again... the second number should be 1 higher.

      do as server
          Text := null;
          let a := this;
          let c := last(select ABC).Id;
          let b := (create ABC);
          let d := last(select ABC).Id;
          Text := text("c is " + c + " and d is " + d)
      end
      

      BUT when I add do as server around the code, it gives me seemingly random results: "c is 9 and d is 45"

      • John_Halls
      • 1 yr ago
      • Reported - view

      Mel Charles Hi Mel, I ran into an issue which gave different results here

      https://forum.ninox.com/t/m1hbwv5/client-vs-server-script-differences

      Regards John

      • Fred
      • 1 yr ago
      • Reported - view

      If you look at table ABC do you see a record with Id of 45? It looks like you only had 9 records at the start and then you added 34 records?

      I did the following in the MacOS app:

      let c := last(select Table1).Id;
      let new := (create Table1);
      let d := last(select Table1).Id;
      empty := "c is " + c + " and d is " + d
      

      and it does what you thought it would.

      c is 25 and d is 26

      • Alex_Mumm
      • 1 yr ago
      • Reported - view

      Fred I did have 45 records, not 9. The text box display the correct numbers when the Do as Server code is removed...

    • Mel_Charles
    • 1 yr ago
    • Reported - view

    Hi Alex

    Well I'm blown away, do as server should not make a difference.

    John - Looked at your thread... Lesson learned " Take all that I know to be true of Ninox and toss it in the bin". Have you tackled support on this mate?

    I use do as server all over the place and don't get any errors (or so i thought! - now worried I might be giving customer vouchers away when I don't need to  😧 ...

      • John_Halls
      • 1 yr ago
      • Reported - view

      Mel Charles Thanks. No I haven't mentioned it to support, it was code I was testing out for someone on the forum, so it's not being used in a production environment. I'll reach out for peace of mind and come back to you.

Content aside

  • 1 yr agoLast active
  • 10Replies
  • 668Views
  • 5 Following