Apply Do It to see what is coming back from TinyDB from all those different tags.
Also apply Do It to those function calls to see what they return.
Also apply Do It to whatever .Selection values you get after selecting.
Then post them here.
Also I suggest making this change to the role(roleName) function, so that it always returns some kind of 3-element list, even though the role name it was given does not appear in the roles table.
Okay, here goes me doing Do it and posting screen shots of the results:
a) Do It on the DB .getValue in the .Initialize screen block:
...it pulls DB info on role names, role vision, and role definition of happiness
Do It on set ListPicker1_RoleReport.Elements to call roleNames:
...returns an error (a red circle with an x in it). So we have a problem here.
Do It on tinyDB .CallValue for set global myGoalList :
...does indeed pull goals values from the DB
DoIt on call TinyDb.GetValue in the to "GetRolesFromTinyDB" procedure :
....does succees in pulling role info from the DB.
DoIt on the "make new list from" within the procedure to "roleNames"
....yields is an error (red circle with the white x) so we have a problem here. No wonder it is not working when called in the intialization block because it is not even working in the "pure" function.
The DoIT on the "make list from mapping each goal to" in the to "goalNames" procedure
...is giving an error.
the "make a new filtered list" block in the to "GoalsWithRole" procedure:
...is giving an error.
The "reduce" block in to "role roleName" block :
...is giving an error
This is probably all the result of one place in the code giving an error, but I am not yet good enough at unit testing to see exactly where that is.
These blocks depend on the TinyDB values returned for tags 'roles' and 'myGoals' being tables (lists of lists).
Unfortunately, Do It does such a good job of text conversion, that you can't tell if the original value was a list or not.
You can test my guess by applying the 'is a list' block to the TinyDB output values, in a Do It.
Then you can test if they are tables, by trying to select items from row 1.
Here is a draggable less gullible version of the roleNames procedure:
By the way, Do It does not work inside procedures, since their data is fleeting.
To test procedure code, copy the guts of the procedure out, and feed the guts directly from TinyDB or global variables.
Apply Do It to expressions, right to left.
a) I'm deeply appreciative you taking your time to put together these blocks. But they don't work.
I'm at that place that I suppose many programmers have been at with this: I'm on the cusp of giving up. I've been working on this problem for a month now.
What's frustrating is that: in a spreadsheet or a MySQL, this would be 30 minutes of work. This is a pretty simple query:
SELECT "goalName" from goals WHERE "roleName" = selection.
I kinda regret doing this in TinyDB. It isn't meant to be relational. Perhaps things would have done better with learning Firebase.
I know this is self-pity but, I'm starting grad school on Oct 1st and I really wanted to have this app done by then. On that date, my focus will change drastically.
Thing is, my instinct tells me I just a few changes away from getting this thing working.
b) You said "These blocks depend on the TinyDB values returned for tags 'roles' and 'myGoals' being tables (lists of lists).
Unfortunately, Do It does such a good job of text conversion, that you can't tell if the original value was a list or not."
I think I can affirm that TinyDB is really storing true "lists of lists" and not just blobs of concatenated text. I have proven than elsewhere in this app by pulling specific indices from the DB and pushing it to ListViewers.
I'm not sure in what form you would like me to show you sample data. On the version in my emulator(on my laptop), there are just a few entries for each table. (role, timeframes, etc).
So I woke up bright and early this morning and decided to treat this as a honest-to-goodness real problem in life; I drew up a problem tree focused on disaggregating the possible root causes with this code.
Here is the whole problem tree (which is probably too grainy to see) :
For better or for worse, I have. I'm striving to become a good problem solver this year.
Business Analytics.
Any insight you can provide would be greatly appreciated.
On my end, I'm going to experiment with creating a straightforward procedure to loop through global roleTable manually and select only the role names, then populate ListPicker from this simple list of names. This might help rule out whether the map block or list indexing is the issue.
What about using the local sqlite database?
There are extensions to access it, for example App Inventor Extensions: SQlite | Pura Vida Apps, which follows the KISS principle - keep it simple, stupid... there are also other sqlite extensions
The error it gives (although now it is for procedure roleNames2, a newer version of this procedure) is the same error it has been giving for about ten days now: "The variable $role is not bound in the current context".
This is the function, as it currently stands, that is attempting to feed that ListPicker: