Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Count instances of additional subforms using instance manager

Avatar

Level 4

I am familiar with using the following code in the calculate event in tables when the instance manager is used to add rows:

this.rawValue = this.parent.index+1;

However, I have a simple form that due to the need to expand the text field, I have used used a subform rather than table. While the instance manager works correctly, the number remains at one for each added instance.

A link to the form is here:

Dropbox - SMP Comments Form.pdf

Any help would be appreciated.

3 Replies

Avatar

Level 10

Hi,

Using .parent only gets you to the StaticPortion object, you need to go one further up, so either use parent.parent or CommentSubform (which is the one that repeats).

If you change your calculate event code to the following you can remove the layout:ready code.


var count = _CommentSubform.count



this.rawValue = CommentSubform.index+1;


Regards

Bruce

Avatar

Level 4

Bruce:

That did the trick; thanks for the advice. Now, if I can ask another question. In testing the distribution of this form (downloadable here:)

Dropbox - SMP Comments Form_distributed.pdf

I have an issue with data binding. The collection response file is only collecting the first instance of the CommentNo, SectionNo, and SMPComment. I have the repeat subform for each data item checked.

Any insights?

Avatar

Level 10

Hi,

Try generating the response file with the maximum number comments that you allow set (so change the min occurs to a big number).

It's a while since I have done one, but am fairly sure there was a trick like that to it.

Regards

Bruce