Expand my Community achievements bar.

SOLVED

How Do I Increment My Counter in Designer ES4?

Avatar

Level 2

I have a numeric field titled Provider_Index, set to a default value of "1".  I need the numeric field to increment by 1 each time I click the button "AddAdditionalProvider."  Below is the current syntax associated with the button, but the counter will not increment.

Suggestions?

form1.EXP_Sample_Form.Buttons.AddAdditionalProvider::change - (FormCalc, client)

if (xfa.host.version < 8) then

    EXP_Sample_Form.Bottom_of_Form.Provider_Type.Provider_Index.rawValue = rawValue + 1

endif

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

sorry for the delay.

If looked at your form and have the following improvements.

I did not understand the whole form logic, because it's quite complex and would take hours for me to figure out everything... so I cannot fix your first request here.

Anyway, here's what I can offer you so far:

Firstly, the counter can be created much much easier. You only have to count the number of instances of the repeated subform that surrounds your count field.

Therefore I would use the following FormCalc script in the calculate event of Provider_Index.

$.parent.parent.index + 1

Secondly the buttons script to add new instances of the Bottom_of_Form subform.

The actions builders script is way to complex and can be deleted.

Also delete the script in the buttons change event, it make no sense here.

Then add this FormCalc script to the buttons click event. Make sure you use FormCalc, because JavaScript does not allow wildcards like [*] to address all instances of an object!

EXP_Sample_Form._Bottom_of_Form.addInstance(1)

EXP_Sample_Form.Bottom_of_Form[*].presence = "visible"

; this part is only needed if the form will be used in Acrobat or Reader 7. Otherwise you can delete it.

if ($host.version lt 8) then

          $form.recalculate(1)

endif

Hope this helps.

View solution in original post

7 Replies

Avatar

Level 10

Do you use Acrobat or Reader below version 8? I can't believe this.

You current script checks the version of the PDF viewer and the script in the if expression will not execut if the version is 8 or higher (current version is 11).

Also, the script itself make no sense to me.

try:

Bottom_of_Form.Provider_Type.Provider_Index = Bottom_of_Form.Provider_Type.Provider_Index + 1

Avatar

Level 2

radzmar

The syntax you suggested does not increment the counter.  I have used rawValue + 1 in another form, but it doesn't seem to work here.

Any other suggestions?

Avatar

Level 10

Can you please share your file as I can't follow your description.

Use any file hosting service like and then post the link here, so I can look at your form.

Avatar

Level 2

radzmar,

My file is at https://www.dropbox.com/s/jr9yzsxrkvqenp5/EXP%20Sample%20Form.pdf

When you click on the "NewContract" radio button, the "NewReasons" sub-form and four document types should appear.  When the "SoloPrac" or "Group" radio butons, then the "Bottom_of_Form", "ProviderType" and "Buttons" subforms appear.  Depending on the selection of "ProviderType" one of two name subforms are added.

The "Provider_Index" counter now increments when I click on the "AddAdditionalProvider" button.  However, I cannot get a new instance of the "Bottom_of_Form" sub-form to appear.  As I add new Providers the counter should increment.

Your help is greatly appreciated.

anokie1

Avatar

Correct answer by
Level 10

Hi,

sorry for the delay.

If looked at your form and have the following improvements.

I did not understand the whole form logic, because it's quite complex and would take hours for me to figure out everything... so I cannot fix your first request here.

Anyway, here's what I can offer you so far:

Firstly, the counter can be created much much easier. You only have to count the number of instances of the repeated subform that surrounds your count field.

Therefore I would use the following FormCalc script in the calculate event of Provider_Index.

$.parent.parent.index + 1

Secondly the buttons script to add new instances of the Bottom_of_Form subform.

The actions builders script is way to complex and can be deleted.

Also delete the script in the buttons change event, it make no sense here.

Then add this FormCalc script to the buttons click event. Make sure you use FormCalc, because JavaScript does not allow wildcards like [*] to address all instances of an object!

EXP_Sample_Form._Bottom_of_Form.addInstance(1)

EXP_Sample_Form.Bottom_of_Form[*].presence = "visible"

; this part is only needed if the form will be used in Acrobat or Reader 7. Otherwise you can delete it.

if ($host.version lt 8) then

          $form.recalculate(1)

endif

Hope this helps.

Avatar

Level 2

radzmar,

Thank you - Thank you - Thank you!!!  I am a novice using this software and do not understand scripting at all.  If Action Builder can't do it for me, I am lost.

Your suggestions worked perfectly.  Now I only have one issue left.

In the top of the form is a drop-down menu that selects what objects will and will not appear in the Bottom_of_Form subform at the bottom of the form.  It work correctly for the first instance, but not for additional instances.  Objects that are supposed to be hidden reappear in new instances of the subform.

Suggestions?

Avatar

Level 10

Do you mean the "LOB_List"?

Well, change the script into:

if ($.boundItem($event.newText) eq "Florida True Health") then

          Bottom_of_Form[*].AncillaryInfo.Data.AHCA.presence = "visible"

          Bottom_of_Form[*].AncillaryInfo.Data.Comments_AHCA.presence = "visible"

          Bottom_of_Form[*].AncillaryInfo.Data.AHCAReceived.presence = "visible"

else

          Bottom_of_Form[*].AncillaryInfo.Data.AHCA.presence = "hidden"

          Bottom_of_Form[*].AncillaryInfo.Data.Comments_AHCA.presence = "hidden"

          Bottom_of_Form[*].AncillaryInfo.Data.AHCAReceived.presence = "hidden"

endif