Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Value of field in a repeating subform

Avatar

Level 2

I have a repeating subform with text fields for City, State and Zip. I want to take whatever the user enters in the first (or only) instance those fields and automatically put that information into a City, State or Zip field in a completely different section of the form.  I just need to copy over the first instance of these fields if there are multiple instances.  I can get this to work if the user adds an instance of the repeating subform and adds a second City, State and/or Zip but I cannot get it to work if there is only one instance of the repeating subform.  It also does not work if the user adds an instance but does not fill in the City, State and/or Zip.  I need it to work regardless of the number of instances.

As an example, here is what I put in the "change" event of the City field (inside the repeating subform) and it works if there is another instance added:

form1.Page3.CityOther.rawValue = form1.Page1.SubformRepeat[0].City[0].rawValue

(This is using FormCalc. I couldn't get JS to work.) 

1 Accepted Solution

Avatar

Correct answer by
Level 7

I would put in the layout:ready event of form1.Page3.CityOther (in formcalc):

if (form1.Page1.SubformRepeat[0].City[0].isNull == 0) then

$ = form1.Page1.SubformRepeat[0].City[0]

endif

That way it has nothing to do with the instance manager and will just make one equal the other if there is a value in the first one.

View solution in original post

6 Replies

Avatar

Level 1

Something like this should work (JavaScript)

var cityCounter = form1.Page3.CityOther.instanceManager.count;

for (var i=0; i<cityCounter; i++)

{

     xfa.resolveNode("form1.Page3.CityOther["+i+"]").rawValue = form1.Page1.SubformRepeat.City.rawValue;

}

Message was edited by: Sooperman23, because of terrible formatting.

Avatar

Level 2

What's the best event to use?  Also, what is the following line of code doing?

     var cityCounter = form1.Page3.CityOther.instanceManager.count;

Page 3 has no repeating subforms.  Only  Page 1 has a repeating subform.

Thanks for your help!

Avatar

Level 1

Ah, I misunderstood the question. If you could upload the pdf I could take a look.

Avatar

Level 2

I don't see a way to upload the PDF. What's the process?

Avatar

Correct answer by
Level 7

I would put in the layout:ready event of form1.Page3.CityOther (in formcalc):

if (form1.Page1.SubformRepeat[0].City[0].isNull == 0) then

$ = form1.Page1.SubformRepeat[0].City[0]

endif

That way it has nothing to do with the instance manager and will just make one equal the other if there is a value in the first one.

Avatar

Level 2

Genius.  I keep avoiding FormCalc but this is the second time it's saved the day for me.  Thank you so much for your help!!!