Expand my Community achievements bar.

SOLVED

XML import to change field state

Avatar

Former Community Member

I am importing xml into a form.  I have some if expressions to change the state of a field based on the value of xml fields. Here is my expression for the color - initialize event: if (Lv= "blue"){ this.fontColor="0,0,204"; }else if (Lv = "black"){ this.fontColor="0,0,0";} Lv is a field from the original form. Here is what's going on - the first fontColor value in the expression gets applied no matter what Lv is equal to. So in this case,  the fontColor ="0,0,204" gets applied even if Lv="black".  It's almost as if the event is ingoring if expression and just pickng up the "this.fontColor" statement. Any ideas?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

In your if statement try a double ==, which you use when testing equality. Also if there are only two incoming colours, you could drop the other if statement and just run with an else.

if (Lv.rawValue == "blue")

{

     this.fontColor = "0,0,204";

}

else

{

     this.fontColor = "0,0,0";

}

Good luck,

Niall

My bad: It depends on how you are bringing in the XML, but I presume Lv is one field receiving XML data. Because the language is javascript, you will need .rawValue for the Lv field.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

In your if statement try a double ==, which you use when testing equality. Also if there are only two incoming colours, you could drop the other if statement and just run with an else.

if (Lv.rawValue == "blue")

{

     this.fontColor = "0,0,204";

}

else

{

     this.fontColor = "0,0,0";

}

Good luck,

Niall

My bad: It depends on how you are bringing in the XML, but I presume Lv is one field receiving XML data. Because the language is javascript, you will need .rawValue for the Lv field.

Avatar

Former Community Member

Thank you that worked. the double quotes did it.