Expand my Community achievements bar.

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

Java Script Help

Avatar

Level 2

I have a table in a form with a Text filed and a Numeric field. I have the text filed populated by a button.  (For instance I have the items Fixed windows, Tilt & Turn Windows, In swing Windows, Project in windows, then I have Doors Inswing French , Outswing, Single doors and so on.) I would like when someone selects an item that was a door in the numeric field if the size is larger then 108” the user would have a popup saying that you must have a size smaller than 108” If they select a window from the list,  the popup would say you must have a size smaller than 80”)

  Your help with this script would be greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Here is the corrected code that is working in Exit event of the Width field.

var intIndex = this.parent.index;

if(xfa.resolveNode("Table1.Row1[" + intIndex + "]").Item.rawValue == "680 Fixed" && this.rawValue >108){
     xfa.host.messageBox("You must have a size smaller than 108");
     xfa.host.setFocus("Width");
}

Two things to correct.

1) In your code you have special characters after 108 (double quotes. You might have copied and pasted. You can check the beginning double quotes and ending double quotes are not the same.)

2) The Row1 is set to be a dynamic section. So always you have to check for the current row to get the field values.

Thanks

Srini

View solution in original post

8 Replies

Avatar

Level 10

You can try like below..

if(TextField1.rawValue == "Single doors" && NumericField1.rawValue >108){

     xfa.host.messageBox("You must have a size smaller than 108”);

     xfa.host.setFocus("NumericField1");

}

Thanks

Srini   

Avatar

Level 2

I tried to put this on exit in the text field but it did not work. I changed the name to my textfield name and my Numeric Field name. What am I doing wrong?

if(TextField1.rawValue == "Single doors" && NumericField1.rawValue >108){

xfa.host.messageBox("You must have a size smaller than 108”);

xfa.host.setFocus("NumericField1");

}

--------------------------------------------------------------------------------------------------------

So I tried this :

if (this.rawValue < 30 || this.rawValue > 80)

{xfa.host.messageBox("Number must be between 30 and 80");

this.rawValue = "";

xfa.host.setFocus(NumericField1);}

And it works now how do I make it dependent on the text field?

Avatar

Level 10

You probably need to put the code in the exit event of the Numeric field where you are actually entering the values..

Earlier you mentioned that you are populating the TextField by a button.

Thanks

Srini

Avatar

Level 2

I put the code on the exit of the numeric box and got noe errors but the code had no effect I did not get a popup box.

This is what I used.

if(Item.rawValue == "680 Fixed" && Width.rawValue >108){

     xfa.host.messageBox("You must have a size smaller than 108”);

     xfa.host.setFocus("Width");

}

Avatar

Level 10

Can you send the form to LiveCycle9@gmail.com, so I can have a look at it.. Please mention where the problem is..

Thanks

Srini

Avatar

Correct answer by
Level 10

Here is the corrected code that is working in Exit event of the Width field.

var intIndex = this.parent.index;

if(xfa.resolveNode("Table1.Row1[" + intIndex + "]").Item.rawValue == "680 Fixed" && this.rawValue >108){
     xfa.host.messageBox("You must have a size smaller than 108");
     xfa.host.setFocus("Width");
}

Two things to correct.

1) In your code you have special characters after 108 (double quotes. You might have copied and pasted. You can check the beginning double quotes and ending double quotes are not the same.)

2) The Row1 is set to be a dynamic section. So always you have to check for the current row to get the field values.

Thanks

Srini

Avatar

Level 2

Nice!!!!!!!!! Great Job Thanks it works fine.