I started using Retool last week to build a mobile app for my company. I have all the screens into place and is filtering the data by screen, that works great and it was super quick. Where I have issues is the following.
They scan a label using the barcode component. After that the following needs to happen:
- Check the label exists
- Check the label belongs to the current "drop" they are doing
- Check if the label is part of a pallet
Once all of the above happen. I need to update the table where the label belongs too setting the fields unload=1, driver=currentdriver, delivered at=getDate(). If it belongs to a pallet it will do the same but lookup the pallet number and update the same information in that table.
Hi @adominicci -- welcome to Retool!
It sounds like you are trying to trigger a series of queries once a barcode is scanned. If you have the queries already build to facilitate steps 1-3 that you listed the triggering process would look something like:
- User scans barcode -- the barcode component should have an event handler that you setup to trigger the next step (checking if the label exists).
- Check label exists query is triggered -- setup the success and failure handlers in this query to trigger the next step or to do something if the query fails... this should be how you trigger the follow-up queries as well.
- If everything has succeeded the way you want the last step should trigger your table update query.
yourQueryName.trigger() and using an async/await function to let the query complete its runtime before moving on.
Scanner Event Handler:
If there's maybe more to the issue you're having let us know with some screenshot examples of how you have the app setup (or an export of the App JSON for others to load and inspect)
Thank you @pyrrho I'll give it a shot the way you have explained.
@pyrrho where can I set this what you mentioned here
" 1. Check label exists query is triggered -- setup the success and failure handlers in this query to trigger the next step or to do something if the query fails... this should be how you trigger the follow-up queries as well."
These would be in the query setup:
I started looking around and had found them . My concern is how many queries I'll end up calling. About 4-5 all together and if I go that route and I plan to use the offline mobile do I need to also load these queries before going offline?
I haven't tested this process out specifically, but part of the query is the ability to cache the query results for a set period of time (Advanced tab of the query setup).
Depending on your use case (say, scanning barcodes in the field) maybe your app would need to run the queries while online but then still have access to the cached data later.
That would be a deal breaker. One of the issues we have is that a lot of times they won't have internet connection.
If you're in an always offline situation at a certain point there really isn't a lot more to do, however, Retool does have the offline mode settings for mobile apps (docs: Configure offline mode | Retool Docs) so that you can build around times where connectivity is intermittent and let the user know when things have/haven't processed and are pending connectivity.