Expand my Community achievements bar.

SOLVED

Repeating subforms within a subform

Avatar

Level 2

Hi

I am producing a form which I want to have repeating reports.  I have created a subform for the report which also contains a section (further subform) which can repeated in the report by clicking a button.  This works fine

When I come to repeat the original report I cannot get the section to repeat itself in the new report, it just repeats in the original report. 

Any ideas?

Many thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Darren,

Have a look at this version, I have moved the code in the drop down to the change and initialise events.

https://sites.google.com/site/livecycledesignercookbooks/ADRC-activity-form-5.pdf?attredirects=0&d=1

Regards

Bruce

View solution in original post

11 Replies

Avatar

Level 10

Hi,

It sounds like you need to use a relative reference to the report subform, it seems you are always referencing the first report when you do the add.  It's hard to tell without looking at the form, is it possible you can upload it somewhere (like google docs) and publish a link in this thread and we can have a look.

Regards

Bruce

Avatar

Level 2

Hi Bruce

Thanks for getting back to me.  The link to the form is at the bottom.

I have had a play around with it and made some progress.  I can now add the repeating subform within the repeating subform okay.  I have had to add a stop command at the end of my loop as otherwise it was adding double the number of subform instances each time I clicked the add another activity button.  Now I am trying to add some validation to the fields but it ovbiously not looping around again as I added the stop command.

So here is what I want the form to do if possible:

1. To be able to add activities to a report as needed.

2. To duplicate that report (i.e for another month)

3. To validate the fields (it works for the first one).

Any help and assistance greatly received.

Many thanks

Darren

http://www.adls.ac.uk/wp-content/uploads/ADRC-activity-form-5.pdf

Avatar

Level 10

Hi Darren,

I have made some changes to the "Add another activity" button, so that it no longer references the first monthly report but the current one.  JavaScript does not have a stop keyword, so that is just throwing an exception, do you have "When exception is thrown" set to break?

Hopefully the new code will help with the rest of your requirements. https://sites.google.com/site/livecycledesignercookbooks/home/ADRC-activity-form-5.pdf?attredirects=...

Regards

Bruce

Avatar

Level 2

Hi Bruce

Many thanks for getting back to me so quickly. It is nearly working correctly but not quite.

When you click on add next monthly report the validation is not working for the new report when you hit the add another activity button. However it does work on the initial report and this is what I am trying to replicate.

Any ideas?

Many thanks

Darren

Avatar

Level 10

Hi Darren,

Sorry about that, seems I left a absolute reference in.  If you don't specify the instance number in the SOM expression it will default to the first one.

Try this

https://sites.google.com/site/livecycledesignercookbooks/home/ADRC-activity-form-5.pdf?attredirects=...

Regards

Bruce

Avatar

Level 2

Hi Bruce

That is really great and works perfectly! Thanks so much for your help and your code looks so much simpler! Last question if thats okay. I have now set the monthlyactivity subform to hidden. I only want to display the Monthly activity subform when the anything to report field is set to yes and when no it removes all the instances of monthly activity subform for that report. At the moment when the subform presence becomes visible and I click the add another activity button it does the validation but then does not add a new instance.

I am thinking that it is something to do with the subform count but would you know an explanation for this and how to fix it. I am not sure why setting a subform to hidden would effect the code?

Many thanks

Darren

Avatar

Level 2

Hi Bruce

I think Ive worked out that it is rendering the next subform as a hidden one.  Not sure how to fix that given your new code?

Thanks

Darren

Avatar

Level 10

Hi Darren,

You did have some exceptions happening in your code, like the stop command which isn't recognised. Once it hits an exception then any code following will not execute.  Check in Acrobat under Edit ... Preferences ... JavaScript that "when exception is thrown" is set to break.

Otherwise link to your new version and I'll have a look.

Regards

Bruce

Avatar

Level 2

Hi Bruce

Many thanks for getting back to me.  The basic problem is that if possible I want the monthly activity subform hidden unless the anything to report drop down list is yes.  However when you click to add a new monthly activity it renders the hidden subform and I cannot work out how to add the relative references to make it visible.  The alternative is that I keep the subform visible but make the initial instance as 0 but again playing around with it yesterday I could not get it to work.  If you are able to have a look would be really really helpful as trying to get this done for work! 

Here is latest form with your code in. You will see what I mean if you set the anything to report to yes and then try and add a new activity.

http://www.adls.ac.uk/wp-content/uploads/ADRC-activity-form-5-master-validation-working.pdf

Best wishes

Darren

Avatar

Correct answer by
Level 10

Hi Darren,

Have a look at this version, I have moved the code in the drop down to the change and initialise events.

https://sites.google.com/site/livecycledesignercookbooks/ADRC-activity-form-5.pdf?attredirects=0&d=1

Regards

Bruce

Avatar

Level 2

Hi Bruce

Brilliant!  The only thing I dont understand is why do you not need to reference the instance manager in the change event of the AnythingToReport field?

Thanks for all your great work and helping me out of a sticky problem.

Darren