I want to try slowing down a lookup query that runs after an insert form has posted a record to the database.
I’m suspecting that maybe my localhost M1 Mac runs the lookup just a smidge too fast to pick up the Conditional Where value that was just posted.
I have the lookup running after the insert query in the same API – and maybe I have to delay it a second. The forum is filled with questions on delaying scheduling but some answers say use the scheduler ON the page to delay the lookup table query — and others say best place is to delay it in the API I’m using – one stop shopping… running synchronously.
But I’m sure the last steps are not correct. I want to delay running the query for 1 second.
Isn’t this a server action?
Don’t server actions run sequentially? So, the "Condition {{$_SESSION.story_ID}} shouldn’t run until your database insert is done.
But now I discover that the slippery little devil of a unique number generator is playing by its own rules.
i think I’m “freezing” it in a given split second of time but … Time waits for no plodding developer.
The unique number I think I’m capturing when I see it in the form input before inserting the form simply updates itself while the form is flying its little packets to the mysql server.
Which is why I can never retrieve the last record by the number I “captured” to use as the query table WHERE $_givenkey = '1650991819"
The record has already been saved with a new sequential unique number.
Programmically there is a way around this but in the meantime I may have to go back to old tried and true last record’s key id fetch.
THANKS to all who have been helping through the stalwart hours!
I have most security issues solved except for why I have a page that refuses to allow any more server connections via the Wappler UI.
There is some jquery related code in Wappler that is putting its little vars down and stamping on my tries.
This waits one second before it runs three queries. I do this because these queries are filtered by variable/form values. So I wait a second for those values to be populated. I probably don’t need a full second but for my use case it works like a charm.
The steps in your server actions are running sequentially, no wait is needed to get the inserted record Identity immediately after the insert step. The steps after the insert will only be executed after the insert is done, which means the id is already available.
Also I see no logical reason to set session then a condition then a query inside a condition.
You just need to place the query step after the insert and directly use the insert identity in your query.