dropdown

Hi,

I have a dropdown with 2 values.

I have a scenario like once after selecting "Cancelled" I have to show a textfield to enter comments and save the details. This I am able to achieve.

But, at the same time I have to remove "Cancelled" option from the dropdown. When I am trying to do that I can getting below specified error.

ERROR:

code:

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Hi,

    Your question is not clear, when do you want to remove Cancelled option from selected drop down list after entering and saving comments?

  • After selecting "Cancelled", I am showing a a!textField, where user is entering Cancel reason. Now, after submitting the form, I should not show the "Cancelled" option anymore.

    But, with my current code, it was throwing an error after submitting the form.

  • some more additional details:

    More details. Local variables used to set the dropdown labels and values.

  • 0
    Certified Lead Developer
    in reply to Hari Kishore Reddy

    you are saying you are submitting the form, If you you submit the form how do you getting this form again, because once submit the form you will navigate back to your dashboard(Or where ever you initially came from). 

    Please try this code if you are writing something on submit button. 

    a!formLayout(
        contents: {
          a!dropdownField(
            label: "Review Options",
            placeholder: "-- Review Options --",
            choiceLabels: local!reviewOptionLables,
            choiceValues: local!reviewOptionValues,
            value: local!selectedReviewOption,
            saveInto: {
              local!selectedReviewOption,
              ri!opinionReviewOption, /*Assuming this is where you are saving final selection */
              /*Resetting your reason every time option is changed*/
              a!save(
                ri!reason,
                null
              )
            }
          ),
          a!textField(
            showWhen: ri!opinionReviewOption = "Cancelled",
            label: "Reason",
            value: ri!reason,
            saveInto: {
              ri!reason
            }
          )
        },
        buttons: {
          a!buttonLayout(
            primaryButtons: {
              a!buttonWidget(
                label: "Submit",
                style: "PRIMARY",
                saveInto: {
                  /*Assuming you are writing data to DB directly here*/
                  a!save(
                    local!selectedReviewOption, 
                    null
                  )
                }
              )
            }
          )
        }
      )

  • 0
    Certified Lead Developer
    in reply to Hari Kishore Reddy

    There are couple of issues in your code. First you are appending null values to your dropdown list. Second,  your save logic is conflicting with you local variable dropdown logic list. Try this code it will work for your case

    a!localVariables(
      local!reviewOptionLables: if(
        ri!opinionData.RequestStaus = "PA",
        {"Additional Info Required", "Cancelled"},
        {"Additional Info Required"}
      ),
      local!reviewOptionValues: if(
        ri!opinionData.RequestStaus = "PA",
        {"AIR", "CED"},
        "AIR"
      ),
      local!selectedReviewOption,
      
      
      
      
      
      a!formLayout(
        contents: {
          a!dropdownField(
            label: "Review Options",
            placeholder: "-- Review Options --",
            choiceLabels: local!reviewOptionLables,
            choiceValues: local!reviewOptionValues,
            value: local!selectedReviewOption,
            saveInto: {
              local!selectedReviewOption,
              ri!opinionReviewOption, /*Assuming this is where you are saving final selection */
              /*Resetting your reason every time option is changed*/
              a!save(
                ri!reason,
                null
              )
            }
          ),
          a!textField(
            showWhen: ri!opinionReviewOption = "Cancelled",
            label: "Reason",
            value: ri!reason,
            saveInto: {
              ri!reason,
          /* Not sure where you have this save logic in your code - Take this logic and place in your code whre appropriate*/
              a!save(
                local!selectedReviewOption,
                null
              ),
              a!save(
                ri!opinionData.RequestStaus,
                if(
                  ri!opinionReviewOption = "AIR",
                  "PA",
                  if(
                    ri!opinionReviewOption = "CED",
                    "CA",
                    ""
                  )
                )
              )
            }
          )
        }
      )
    )