how to save previous selected value of dropdown in local variables?

Hi ,

    I am having a drop down with 4 choice values A,B,C,D. Based upon the value selected for Eg; D, a  section will appear below.

My requirement is

  1. when the drop down value selected is D, then below section should be refreshed i.e. set the section fields to null
  2. if the drop down value selected is either D to A or A to D or B to D or C to D , then below section should be refreshed i.e. set the section fields to null.
  3. if the drop down value selected is either B to A or A to C or B to C, then below section should not be refreshed.

so for this requirement i want to save the previous selected value of dropdown to compare with the latest selected value in order to do the refresh.

please provide your suggestions or any other idea to do this requirement.

Thanks in advance

Pradeep.B

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    The above posted code will work (though i'm unclear what "should be refreshed" really implies from your initial requirement description); however I'd personally recommend simplifying if possible and just using stacked saveIntos to save a single "last value" historical copy whenever the dropdown is changed.  You can then (i assume) store your logic for the "refresh" condition in a subsequent local variable, which will refresh anytime either of the earlier values gets changed.

    a!localVariables(
      local!values: { "A", "B", "C", "D" },
      local!currentSelection,
      local!oldSelection,
    
      local!isRefresh: if(
        isnull(local!oldSelection),
        "",
        "" /* put refresh logic here */
      ),
    
      {
        a!dropdownField(
          label: "Dropdown",
          choiceLabels: local!values,
          choiceValues: local!values,
          placeholder: "--select a value--",
          value: local!currentSelection,
          saveInto: {
            a!save(
              local!oldSelection,
              local!currentSelection
            ),
            a!save(
              local!currentSelection,
              save!value
            )
          }
        )
      }
    )

Reply Children
No Data