Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Repeating subform is duplicating checkbox and calculated values

Avatar

Level 3

Hello, all;

I'm building a form with LiveCycle that has some sections for filling in travel data (numeric fields for hotel lodging rate, incidental expenses, transportation, a total cost field summing all the expenses, and a couple checkboxes for room availability). The form starts out with 3 instances of these sections and the client wanted the last one to have buttons to add/remove additional hotels, as needed. Based on this, I created the repeating subforms, and all seemed to work fine until I tested it and found out that the checkboxes (which really don't have any additional functionality) duplicate their checked value when a subform is added. I also noticed that the total cost field duplicated the value from the previous subform as well, despite different data input within its own section (see screenshot).

screenshot_aem.png

I'm guessing this has to do with the naming or something. What do I need to do to fix this? Do I need to look into arrays so the subsequent subform and field names don't get copied as the user adds new sections? If you need anything else from me, please let me know.

I really appreciate your help.

1 Accepted Solution

Avatar

Correct answer by
Level 7

If your code knows that instance has been created, you can target which instance to clear. You can use the instanceManager to count the instance and then reference the new instance to clear the fields and not affect the rest.

This link gives a brief example of instance counting and referencing

Mirror data from another table in form

As you create the new instance, you can then clear fields based on it's instanceManager.count

View solution in original post

11 Replies

Avatar

Level 7

I would expect you could just change the rawValue of these items after the code in your Add Another Hotel button. Change the checkboxes rawValue to 0 and the calculated field to null.

Avatar

Level 10

Hi,

It should work the way you want, each new instance will get the default values.  Can you post the code in the "Total Costs ..." calculation and a screen shot of your field hierarchy.  Or, if possible a link to your form.

Bruce

Avatar

Level 3

@BR001;

Yeah, I thought that too. The last time I did a repeating subform, it was with a table and everything worked fine (although that one only had one checkbox per row - but still the values weren't duplicated or anything when the new instance was created). That was a while ago though. I actually referenced that form while creating this one instead following all the tutorials on how to do it all over again. For the most part, it worked just fine.

Here's a screenshot.

screenshot_aem2.png

Avatar

Level 3

@MinusZero;

I tried that (unless I did it wrong) and it cleared the value of the previous instance, too. Plus, if I check the box in the new instance, it is checked again in the previous one.

Avatar

Level 3

Do I need to use file sharing services to link the file? I don't see any upload button or anything. What do y'all recommend?

Thanks

Avatar

Correct answer by
Level 7

If your code knows that instance has been created, you can target which instance to clear. You can use the instanceManager to count the instance and then reference the new instance to clear the fields and not affect the rest.

This link gives a brief example of instance counting and referencing

Mirror data from another table in form

As you create the new instance, you can then clear fields based on it's instanceManager.count

Avatar

Level 10

Hi,

I'm even less sure how your form works now as you seems to have four sfHotelNameLocationX subforms, I was expecting one that repeated.  Also, because TotalCostAccomodation3 and HotelRate3 are siblings in the structure you can change the reference you have Main.sfHotelNameLocation3.HotelRate3.rawValue to just HotelRate3.rawValue, which would mean you have the same code in all the places.

So, now I guess we neeed to know how the add buttons works.

Pretty much any of the file sharing sites are fine, dropbox is free.

Bruce

Avatar

Level 3

Thanks for this. Sorry about the delay; had gotten retasked for a little bit but eventually got back around to the form, read, and re-read your comment and the comments in your link and was able to figure out the changes I needed to make.

I really appreciate your help; and so does my client.

Have a great day!!

Avatar

Level 3

Yeah, I had created the 4th subform just trying to see if I could accomplish the same results with having a hidden subform but it obviously didn't work so I ended up not needing it. Now that it works correctly, that subform has since been deleted.

I have a couple other projects coming up that will require the same methodology (for the same client) so I'm definitely looking forward to being able to knock these out much quicker than I did trying to figure this one out... LOL.

Thanks again.

Avatar

Level 3

Hello, thanks for the earlier suggestions. I'm still having issues with the checkbox in the repeating subform duplicating. I'm probably not understanding/applying the suggestions that were made in the link that was provided. So, I'm back to see if anybody can provide some guidance. Here's a link to my file on Dropbox:

https://www.dropbox.com/s/otzhfmjum8rq48z/AEM_072618.pdf?dl=0

I really appreciate your help. Keep in mind, I was trying a number of different methods to get it to work so you may have to disregard some coding that you'll find.

Let me know if I need to modify any settings in Dropbox to get access to the file.

Thanks,

Avatar

Level 3

I figured out what my problem with the checkboxes was...

I had Data Binding set to "global". Selected "Use name..." instead, everything works as intended now.

Thanks!!