Cascading dropdown K12

Sylvain C. asked on March 11, 2020 20:14

Good morning, For my pagetype, I have 2 dropdowns (ddl1 field and ddl2 field). I would like the ddl2 to be dependant of the ddl1.

I tried several syntaxes such as this one but I keep getting an dataconnection error:

Form control: drop-down list
SQL query:

SELECT [ddl2_Code], ddl2_Name
FROM Mytable
WHERE LEFT(ddl2_Code,1) = {%fields.ddl1.Value#%}
ORDER BY ddl2_Name

If I remove {%fields.ddl1.Value#%} and replace it by whatever fits, it works... How can I achieve that? Ideally, I would also like the ddl2 to be refreshed when the ddl1 is changed. I tried to play with "Has depending fields" and "Depends on another field" but with no success.

Thank you

Correct Answer

Sylvain C. answered on March 11, 2020 20:37

OK I was able to do it by doing the following:
ddl1:
Has depending fields: Yes

ddl2:
Depends on another field: Yes
Enabled condition: !String.IsNullOrEmpty(ddl1.Value)
SQL query:

SELECT [ddl2_Code], ddl2_Name
FROM Mytable
WHERE LEFT(ddl2_Code,1) = {%ddl1.Value#%}
ORDER BY ddl2_Name

Hope it will be useful to someone else

0 votesVote for this answer Unmark Correct answer

Recent Answers


Roberto Gonzalez Jr answered on January 10, 2021 00:56

Did you get this to work? I have something similar but I need it to refresh. How did you get it to refresh?

select [ItemID],Slots
from custom_table
WHERE LEFT (ItemID,1)={%Date.Value#%}
ORDER BY Slots

Mine does not refresh when I choose from drop-down Date

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.