Expand my Community achievements bar.

SOLVED

How to expand rows in a table by calculated value of a field

Avatar

Level 3

Hi,

I'm trying to set the rows of an expandable table to follow the calculated value of a field.

The calculated field comes from two date fields that calculate the number of days and I want my table/row to expand based on that number..

Is is possible? Right now I have a button that does add an instance  "Admin_Use.Table3._Row1.addInstance(1);" but I want it to be triggered by the calculated field instead...

Thank you so much!!!!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=AmNfJzA-jGLL9-moO888IA.

Have a look at the script in the calculate event of the TotalDays. Because you are using the calculate event it is important that you set the number of instances of the row first and that the last line of script in that if statement is setting the value of the object ($ = i).

Hope that helps,

Niall

View solution in original post

6 Replies

Avatar

Level 10

Hi,

I suspect that you can achieve this, but it would depend on what value triggers it. For example if the difference between the two dates is greater than 10.

The following in the calculate event of the field:

var nDays = // difference in two date fields

if (nDays > 10) {

     Admin_Use.Table3._Row1.addInstance(true);

}

this.rawValue = nDays;

If the calculate event the last line of the script has to be setting the value of the field.

Hope that helps,

Niall

Avatar

Level 3

Hi Niall,

Thank you for your reply. I'm still a bit puzzled as right now I have this code in my calculate field (see below) under the calculated event and I'm not sure how to insert the code you sent me as I keep getting syntax errors. Any help will be greatly appreciated!!!

if (HasValue(Nights.FirstNight) & HasValue(Nights.LastNight) ) then

    if (Date2Num(Nights.LastNight, "YYYY-MM-DD", "en_IE") >= Date2Num(Nights.FirstNight, "YYYY-MM-DD", "en_IE")) then

        $ = Date2Num(Nights.LastNight, "YYYY-MM-DD", "en_IE") - Date2Num(Nights.FirstNight, "YYYY-MM-DD", "en_IE") + 1

   

else

        xfa.host.messageBox ("The first night cannot be after the last night", "Nights Covered", 0)

        Nights.LastNight.rawValue = null

   

endif

else

    " "

endif

Avatar

Level 10

Hi,

Can you share your form or the part which is causing you trouble? If so, upload it to a file sharing site like Acrobat.com; publish it and then post the published URL here.

Niall

Avatar

Level 3

Hi Niall,

Thank you for your help. The field (TotalDays) I'm having problems with is located on the first page and I'd like it to trigger the number of rows to be displayed on the table located on subform called Admin_Use. Table3, row1. So, in order words, if the number of night on the TotalDays field is 4, I want the table to show 4 instances (rows).

I have uploaded the form here (see below). THANK YOU SO MUCH!!!!

https://acrobat.com/#d=Eqbhf-wjPi7Q-6bot9VsLQ

Avatar

Correct answer by
Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=AmNfJzA-jGLL9-moO888IA.

Have a look at the script in the calculate event of the TotalDays. Because you are using the calculate event it is important that you set the number of instances of the row first and that the last line of script in that if statement is setting the value of the object ($ = i).

Hope that helps,

Niall

Avatar

Level 3

Awesome!!! Thank you very much!!