Skip to main content
kavyam0002
February 20, 2024
Solved

Logic

  • February 20, 2024
  • 4 replies
  • 1 view

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

    Best answer by niranjanreddym9323

    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
    February 20, 2024

    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
    February 20, 2024

    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. 

    March 12, 2024

    Any update?

    konduruc733182
    March 12, 2024

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