Skip to main content
kavyam0002
Brainy
Feb 20, 2024 5:26 AM UTC
Solved

Logic

i have condition, where 2 questions are dependent on each other

when i select 1st Q as YES then next Q auto select to NO

if 1st select as NO then no action of 2nd Q

if second Q is YES then 1st to be auto select to NO

if second Q is NO then no action for 1st Q

    niranjanreddym9323
    Participating Frequently
    Feb 20, 2024 5:39 AM UTC

    a!localVariables(
      local!q1,
      local!q2,
      {
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!dropdownField(
                choiceLabels: {"Yes","No"},
                choiceValues: {"Yes","No"},
                label: "Question 1",
                labelPosition: "ABOVE",
                placeholder: "--- Select a Value ---",
                value: local!q1,
                saveInto: {
                  local!q1,
                  if(
                    local!q1="Yes",
                    a!save(
                      local!q2,
                      "No"
                    ),
                    {}
                  )
                },
                searchDisplay: "AUTO",
                validations: {}
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!dropdownField(
                choiceLabels: {"Yes","No"},
                choiceValues: {"Yes","No"},
                label: "Question 1",
                labelPosition: "ABOVE",
                placeholder: "--- Select a Value ---",
               value: local!q2,
                saveInto: {
                  local!q2,
                  if(
                    local!q2="Yes",
                    a!save(
                      local!q1,
                      "No"
                    ),
                    {}
                  )
                },
                searchDisplay: "AUTO",
                validations: {}
              )
            }
          ),
          a!columnLayout(
            contents: {}
          )
        }
      )
    }
    )


    Hi [mention:bd2e537916fe4b31980bfba549754efc:e9ed411860ed4f2ba0265705b8793d05] ,

    try the above code and see if it works for you

    4 replies

    niranjanreddym9323
    Participating Frequently
    Feb 20, 2024 5:39 AM UTC

    a!localVariables(
      local!q1,
      local!q2,
      {
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!dropdownField(
                choiceLabels: {"Yes","No"},
                choiceValues: {"Yes","No"},
                label: "Question 1",
                labelPosition: "ABOVE",
                placeholder: "--- Select a Value ---",
                value: local!q1,
                saveInto: {
                  local!q1,
                  if(
                    local!q1="Yes",
                    a!save(
                      local!q2,
                      "No"
                    ),
                    {}
                  )
                },
                searchDisplay: "AUTO",
                validations: {}
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!dropdownField(
                choiceLabels: {"Yes","No"},
                choiceValues: {"Yes","No"},
                label: "Question 1",
                labelPosition: "ABOVE",
                placeholder: "--- Select a Value ---",
               value: local!q2,
                saveInto: {
                  local!q2,
                  if(
                    local!q2="Yes",
                    a!save(
                      local!q1,
                      "No"
                    ),
                    {}
                  )
                },
                searchDisplay: "AUTO",
                validations: {}
              )
            }
          ),
          a!columnLayout(
            contents: {}
          )
        }
      )
    }
    )


    Hi [mention:bd2e537916fe4b31980bfba549754efc:e9ed411860ed4f2ba0265705b8793d05] ,

    try the above code and see if it works for you

    harshitb6843
    Brainy
    Feb 20, 2024 5:39 AM UTC

    You can easily do this manipulation in the component's saveInto. Check for the value and using an if() statement, simply do the required manipulation. 

    New Participant
    Mar 12, 2024 9:33 AM UTC

    Any update?

    konduruc733182
    Inspiring
    Mar 12, 2024 9:36 AM UTC

    [mention:62b718b4b0e04ccc9421b55d4701aca0:e9ed411860ed4f2ba0265705b8793d05]  What update are you looking for? This question has been answered.