I’ve just encountered an odd issue with executing dataItem.get().get() command
Thing is that we need to get data from inside a data type contained another data type
E.g. User has Profile and we need to get data from Profile
For some reason, using User.get(Profile).get(someTextData) isn’t working and doesn’t throw any error. Plugin just stops working at the User.get(Profile).get(someTextData) execution.
After some reloads I was able to execute the command for a few times but not completely.
Logging in “User.get(Profile)” and .get(someTextData) inside browser console works fine.
is this inside an element? Is the field name used as parameter for the .get the display id of the field or the actual bubble id (the one you see inspecting app.user_types)?
Ye, it worked but odd way
Script was able to retrieve like 4 out of 5 calls and just terminated
But I was able to reach this only 1-2 times by reloading and tweaking the calls
Making a call, e.g. const profile = user.get(Profile), print in console, save as console variable and call .get(someTextData) again works as well
User is a data type, Profile is another data type inside User, that’s correct
User can have only 1 Profile is correct statement either
Regarding to async calls, I’ve tried to handle the call like async but no result as well
Wasn’t able to find anything on forum and inside docs either but it looks to me like a common issue so wanted to ask for help on forum, so to avoid walking blindly
Ye, this is inside the element, field name used as parameter
I ensured that data used was properly received and making such call in the browser console works
Call randomly executes but I wasn’t able to find a stable solution
Tried it the way you described and also was thinking about syncing but no result, unfortunately
I’ve also tried to handle first .get() as promise (dunno if Bubble changed the structure without announcement) but no effect as well
But agreed that it still sounds and looks like sync issue
as far as I know client side plugins are not async, they still use the previous architecture: when the code runs any data access blocks the execution on the first run, then once the data is available the code runs again from the beginning. If you access different data multiple times the code will actually run multiple times, and only the last one will have all the data available and will run completely.
If your field name is correct what you are probably seeing is multiple partial runs and the the complete run with all the data.
Your code need to account for this behaviour and execute side effects only after you access all the data you need.
It goes without saying that any data access in an async function inside client side plugins will not behave as you expect, maybe this is the problem.
Thank you for your response
I’ve tried this but unfortunately, it is for server-side actions only
Using async function(instance, context) will trow an error for element actions
That sounds useful to note, thanks!
Will give it a shot.
I guess, that we should collect the data at first and check if everything’s fine before proceeding