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).
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.
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
As you create the new instance, you can then clear fields based on it's instanceManager.count
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 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!!
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:
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.
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.
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.
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.