Hi team
I'm needing some help to force an answer in a dropdown field where a given answer is selected in another dropdown field.
Here is a screenshot of the editable grid.
I want to force "not used" in the "how important" column when "never" is selected in the "how often" column
The software names are returned from an existing table.
This is how the answer table is set up:
The questionId corresponds to the two column headings.
Here's the expression for teh editable grid:
{ /* For the Software Title Column*/ a!richTextDisplayField( value: a!richTextItem( text: fv!item.softwareID.name, color: "ACCENT", size: "MEDIUM", style: "STRONG" ) ), /* For the Frequency Of Use and Vitality Columns*/ a!forEach( items: fv!item.surveyResultUserResponse, expression: a!dropdownField( placeholder: "Select", choiceLabels: fv!item.question.allowedAnswer.name, choiceValues: fv!item.question.allowedAnswer.name, value: fv!item.answer, saveInto: { fv!item.answer }, required: true ) )
I'm stumped!
I would greatly appreciate answers with sample expressions, please
Thanks
Stephen
Discussion posts and replies are publicly visible
I typically implement this by first having the "How Often" dropdown perform an a!save() to update the neighboring "How Vital" column, setting it to Not Used when Never is selected, then have the How Vital column become disabled in the same scenario. You could take this further and prevent "Not Used" from being selected with validation when any other selection of How Often is selected, or have the How Often selection simply clear the How Vital selection whenever it is toggled otherwise, etc.
Essentially, you can easily reference data points across the row when you need to check other values:
a!localVariables( local!howOften: {"Daily","Weekly","Monthly","Quarterly","Never"}, local!howVital: {"Vital","Important","Useful","Not Useful","Not Used"}, local!data: { a!forEach( items: 1+enumerate(4), expression: a!map(id: fv!item, software: concat("Antivirus ",fv!item), howOften: null, howVital: null) ) }, a!gridLayout( headerCells: { a!forEach( items: {"Software","How often do you use this?","How vital is this to your work?"}, expression: a!gridLayoutHeaderCell(label: fv!item) ) }, rows: a!forEach( items: local!data, expression: a!gridRowLayout( id: fv!index, contents: { a!richTextDisplayField( value: a!richTextItem( text: fv!item.software ) ), a!dropdownField( placeholder: "-- Select --", choiceLabels: local!howOften, choiceValues: local!howOften, value: fv!item.howOften, saveInto: { local!data[fv!index].howOften, if( local!data[fv!index].howOften="Never", a!save(local!data[fv!index].howVital,"Not Used"), {} ) } ), a!dropdownField( placeholder: "-- Select --", choiceLabels: local!howVital, choiceValues: local!howVital, value: fv!item.howVital, saveInto: local!data[fv!index].howVital, disabled: local!data[fv!index].howOften="Never", ) } ) ) ) )
I was thinking of this too, but usually I personally prefer to wait until they can actually write out the desired user experience (since there's a bad habit around here of tossing out super vague design requests and expecting us to just fill in the blanks).
(And also because i want to make sure they're actually going to participate in their thread, before going through the effort of actually banging out some example code.)
I hear ya, I just happened to have some handy for this basic scenario. And sometimes holding your breath for:
Mike Schmitt said:wait until they can actually write out the desired user experience
..doesn't always end up well for your health :)
LOL yup, though that makes it easier to remain mentally uninvested in the thread ;-)
Thanks Chris, have been working on another part of my project since your answer. I will give this a bash and let you know how I do