I have an interview using the mandatory code block approach (i.e. where the mandatory code block tells DA which questions to ask, as here: https://docassemble.org/docs/logic.html#bplogic).
Everything has been going swimmingly, except now I am trying to determine if a question should be asked, based on the value generated by the preceding question using states_list()
(https://docassemble.org/docs/functions.html#states_list).
So I have something like this:
---
mandatory: True
code: |
country_code = country
ask_for_state = bool(states_list(country_code))
if ask_for_state:
state
You can see I've gone down the rabbit-hole because I'm using bool()
to define ask_for_state
. his works fine for most countries (the US, Canada, France, the UK, etc.), so state
is being defined correctly. What's weird/unexpected is that even though ask_for_state
is false
in the raw data ("ask_for_state": false
), I'm still getting the question for state
popping up right after selecting country
.
All I can think is that DA is "pre-queuing" the question, so that when it's asking for country
, it has already decided it's going to ask for state
.
Not the behavior I want, because for example Saint Pierre and Michelon have no states, so you get really weird behavior in terms of the way the question displays (it essentially asks you to select a state from a null list, not to mention subdivision_type(country)
displays "None".
Wondering if anyone can lend any insight?
PS - I also noticed an issue where subdivision_type()
for Singapore returns 'division' with a lower-case 'd', which is sort of weird because "State," "Province," etc. all come in with the first letter capitalized.
Edit (2022-Jul-16): I feel silly... later on, I was accidentally asking for state
. Always nice to have a second set of eyes, thank you! :)