Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

If statement not picking correct values from a dropdown list

Avatar

Former Community Member

I have a subform that is added through an instancemanager.addInstance method.

In this subform there are 2 dropdowns. Depending on what is selected in the first dropdown, the second dropdown would update with an appropriate value. For some reason only the LAST statement is being applied no matter the selection is made on the first dropdown.

This is what I have

if (this.resolveNode("subrow").ddlField.rawValue=1)

     {

     this.resolveNode("subrow").ddlECapField.rawValue=7

     }

if (this.resolveNode("subrow").ddlField.rawValue=2)

     {

     this.resolveNode("subrow").ddlECapField.rawValue=4

     }

if (this.resolveNode("subrow").ddlField.rawValue=3)

     {

     this.resolveNode("subrow").ddlECapField.rawValue=6

     }

If I use "else if" instead of the "if" I only get the first value no matter what is selected.

3 Replies

Avatar

Level 10

Hi Nick,  You need to use "==" in the if statement for comparison, using one "=" will assign the value and then test for the result being zero (false) or non-zero (true), Regards Bruce

Avatar

Former Community Member

Thank you, i knew it had to be something easy. I also found an alternative:

Switch(this.rawValue)

{

     case "1":

          this.resolvenote("ddlECapField").rawValue=7

          break;

     case "2":

          this.resolvenote("ddlECapField").rawValue=4

          break;

     case "3":

          this.resolvenote("ddlECapField").rawValue=6

          break;

}

The one drawback it seems of this one is that it only seems to work on "exit" and doesnt work on "change"

Avatar

Level 10

You can get it to work on the Change event by using the following:

switch(this.boundItem(xfa.event.newText));