Skip to Content
Author's profile photo Rick Chatterjee

How to detect conditional page break in Adobe Forms in master page using JS.

We need a global variable to change the value of it to use it as a flag to detect a the conditional break in java script.

While printing the table details we can detect the values of the current page and as well the previous page.

We will compare the field value of the present page with the previous page dynamically(while printing the output) and then we can change the global variable (flag) to detect the change in value.

 

Step 1 :  Click on ‘EDIT’ of adobe form layout as shown in the picture


/wp-content/uploads/2015/12/step1_854202.png


Step 2: Click on form properties and the below popup will be displayed.


/wp-content/uploads/2015/12/step3_851480.png


Step 3: Click on variables and the below screen will be displayed.


/wp-content/uploads/2015/12/step4_851481.png


Step 4: Click on ‘+’ and add your variable and set a initial value as 1. I have taken brea here.

Step 5: Take a variable field in master page and open script editor of it. Please follow the below pseudo code to write the code. Write your code in ‘Ready Layout’ event in java script:

               A.          var thispage = xfa.layout.page(this);

                             var fields = xfa.layout.pageContent(thispage-2, “field”);

               this will give the previous page values of the current page and put the required field value to  another variable ‘lv1’.

              

               B.         var fields1 = xfa.layout.pageContent(thispage-1, “field”);

              

               this will give the field value of the current page and put the required field value to another variable ‘lv2’.

                   

               C.  Write the below code to change the flag value:

                   

                         if ( lv1 == lv2 )    // this will change the flag value as ‘1’ if page break is not found

                              {

                                       var r = brea.value ;   

                                            r = 1 ;

                                       brea.value = String(r) ; // Here you can do your calculations

                               }

                         if ( lv1 != lv2)   // this will change the flag value as ‘0’ if page break is found

                              {

                                  var zero = 0;

                                  brea.value = String(zero) ;

                              }

        this.rawValue = brea.value ;  // this will display the flag value in the screen



  • As the table field in the form, one page consists same value in the case of conditional page break. At the changing point of that particular table field value the flag will be 0.
  • You can use it to display subtotals, changing icons based on item category, display or hide according to the main table field value etc.
  • Else condition was not working while writing this java script code. Please like if it is helpful and mention improvement comments on it.

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Did not work for me. I tried assigning direct value to brea in ready:layout event. It did not get triggered.

      It seems the event was the problem. So, not sure about javascript.

      Author's profile photo Rick Chatterjee
      Rick Chatterjee
      Blog Post Author

      You have to change 'brea.value' to change the value of the global variable.

      Did you tried using this ?