Expand my Community achievements bar.

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

Set value on field from another Page

Avatar

Level 2

Hi there,

I'm still a bit new to this, thanks to the forums I've managed to learn a lot. But I've encountered another difficulty.I

I've created a form in LiveCycle with two pages. On page 1 the costs are calculated by multiplying field1*field2 and adding the value of another one. I've managed to accomplish that with the following code:

this.rawValue=(Field1.rawValue*Field2.rawValue)+Field3.rawValue

Like I said, that seems to work.

On Page 2 I have a dropdown with five different options. In the Object > Value tab I checked Specify Item Values but didn't change a thing. So the option value go from 1 to 5.

When option 5 is checked I want to set a value for a field which is located in Page 1. I've tried this with the following script:

if (this.rawValue = 5){

     Page1.positionedSubform.Field3.rawValue = 149;

}else{    

     Page1.positionedSubform.Field3.rawValue = 0;

}

I'm now scripter at all, but this seems to work in a way. Except not the one I want :-).

When I preview the PDF it auto sets the value of Field3 and the dropdown field to 149.

I would like to set Field3 on Page1 to 0 default (as is entered in the Object > Value tab of Field 3) and set it to 149 when option with the value of 5 is chosen in the dropdown on Page2.

Any ideas?

(Sorry for the bad explanation, not sure how to explain it better though)

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Have you used the calculate event in the dropdown?. If so move the script to the exit event of the dropdown.

Niall

View solution in original post

4 Replies

Avatar

Level 10

Hi,

When testing in an if/else statement you need to use a double equal sign. I would also test against a string value, within quotation marks:

if (this.rawValue == "5") {

     // Your script here...

}

Hope that helps,

Niall

Avatar

Level 2

Allright, when I change my code with the one above it auto sets Field 3 to 0. But the dropdown box also shows a 0 :S.

Avatar

Correct answer by
Level 10

Hi,

Have you used the calculate event in the dropdown?. If so move the script to the exit event of the dropdown.

Niall

Avatar

Level 2

YES! That was it :-). Thanks again, that part is working smoothly right now. Pretty proud of it too, since I didn't know about scripting at all