Expand my Community achievements bar.

SOLVED

Calculated fields auto-locking?

Avatar

Level 2

I use LiveCycle off-and-on to make forms and I've seen this issue before. I'm not sure if it's something LC is supposed to do or if I've been doing something wrong all along and didn't know it. The code below is currently applied to the change event of a drop-down box. The idea is simply to have another field change rawValues whenever an option in the drop-down is selected. This works fine upon opening the form.

The problem is that the other field seems to lock up after the form filler has made their selection. For example, if a form filler selects "text3", the result will be "Num3". If the filler made a mistake and then selects "text2", the result will not change from "Num3" to "Num2", it will remain as "Num3". The end result is that if anyone makes a mistake the form has to be closed and reloaded all over again, making them start over from scratch.

I put up with it in the past because my forms were always small one-pagers, but I'm about to make something over multiple pages with a variety of interdependent options. I can't have my users making a mistake halfway through and having to reset the whole thing. Why are the results locking and what can I do to make it stop?

if(this.rawValue = "text1") {PartNum.rawValue = Num1}

   else{if(this.rawValue = "text2") {PartNum.rawValue = Num2}

      else{if(this.rawValue = "text3") {PartNum.rawValue = Num3}

         else{if(this.rawValue = "text4") {PartNum.rawValue = Num4}

            else{PartNum.rawValue = ""}}}};

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hi ,

It looks like you have some misplaced brackets in your code, and you are using a single '=' sign, this assigns a value to the variable and is always true, whereas you need to use '==' to compare values, try the code below

I have spaced it out a bit to make sure I got the sections correct.

if(this.rawValue == "text1")

{

    PartNum.rawValue = Num1

}

else if (this.rawValue == "text2")

{

    PartNum.rawValue = Num2

}

else if (this.rawValue == "text3")

{

    PartNum.rawValue = Num3

}

else if (this.rawValue == "text4")

{

    PartNum.rawValue = Num4

}

else

{

    PartNum.rawValue = "";

};

Hope this helps

Malcolm

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

Hi ,

It looks like you have some misplaced brackets in your code, and you are using a single '=' sign, this assigns a value to the variable and is always true, whereas you need to use '==' to compare values, try the code below

I have spaced it out a bit to make sure I got the sections correct.

if(this.rawValue == "text1")

{

    PartNum.rawValue = Num1

}

else if (this.rawValue == "text2")

{

    PartNum.rawValue = Num2

}

else if (this.rawValue == "text3")

{

    PartNum.rawValue = Num3

}

else if (this.rawValue == "text4")

{

    PartNum.rawValue = Num4

}

else

{

    PartNum.rawValue = "";

};

Hope this helps

Malcolm

Avatar

Level 2

Curious, I was sure I needed those brackets after "else". And I forgot entirely about the difference between == and =. That's what I get for not working with LC/Java for months.

That works, thanks!