0

Execute script in background

Our setup

In our database there is a script that executes when a certain field is changed: If ZIP-Code A is changed, check the lookup table for a matching city, then write the name of the city in the city field.

Additionally, this script contacts the OSRM server to calculate the route from A to B, then write the result into the route field. The server call needs to be done inside "do as server ... end", because we are mainly working with the Ninox app for macOS.

These are the 3 relevant fields in our database:

  1. ZIP-Code A
  2. City A
  3. Calculated route (kilometers) from A to a fixed location

Ideally, this takes less than 1 second.

 

The problem

Sometimes the OSRM server takes several seconds to provide the route results. In that case the following happens:

The user changes ZIP-Code A and confirms with enter. ZIP-Code A briefly returns to its previous value. City A stays the same. After a few seconds, both ZIP-Code A and City A change according to the user's entry.

 

What we want

There should be close to no pause after the user confirms the ZIP-code change with enter. The new ZIP-code should instantly appear in the field upon entry.

The user should be able to continue with other fields although the calculated route field is not yet properly filled with the calculated value from the OSRM server. This is already the case.

 

Our question

Is there a way to make Ninox either:

- execute the first part of the script (ZIP-Code A entry changes City A), then retrieve the info from the OSRM server

OR

- retrieve the info from the OSRM server in the background?

 

Tested and not working

ZIP-Code A entry changes City A. The OSRM server call could be triggered on change of the City A field. 
-> the script in the ZIP-Code A field does not trigger that.

"do as transaction ... end" and "do as deferred ... end" both do not work, because we need the server call to be inside "do as server ... end".

Reply

null

Content aside

  • 8 days agoLast active
  • 25Views
  • 1 Following