Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Two buttons, same code, different results

Avatar

Former Community Member
I have two buttons on a form that call the same method in a script object. They are returning different results depending upon which button makes the call. I created a simple test to demonstrate this. Below is the function.



function test(name)

{

console.println("clicked button " + name + " length now = " + xfa.resolveNodes("CaseInfo.ApplicationPage.Comments.ItemHolder.CommentItem[*]").length);



}



Here is what appears in the console when I click on button 1 then buton 2 then button 1 again.



Button clicked : TabButton1 - length = 2

Button clicked : TabButton2 - length = 0

Button clicked : TabButton1 - length = 2



The object referenced does have two instances. The buttons are on different subforms but the object reference is fully qualified.



Why would the second button lose the object reference?
4 Replies

Avatar

Former Community Member
Could you make your form available online somewhere? I'd like to take a look and see why that's happening.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Chris, Thanks for the offer of help but I found a work around for what I am pretty sure is a bug. There was a subform ( CaseInfo.ApplicationPage.Information.CaseInfo ) through trial and error I found that if I removed that subform from the pdf the code worked correctly. I renamed the form to CaseInfo.ApplicationPage.Information.CaseInformation and everything worked correctly.



I do have another problem with this form. I have an ODBC data connection with fields on a subform bound to it. The subform is set to repeat for each data item. When the form loads if there are multiple data rows returned. I only get a single instance of the subform. If I add additional instances, subform.instanceManager.addInstance(1), the new intanstance is also bound to the first row. I know I have multiple rows because calling next on the source then shows the next rows values in both instances of the subform.



Am I missing something. How can I get this to show all the rows? Do I have to write code to bind each row to an instance of the subform? I can email you a simple form that demonstrates this.



BTW - I also tried calling addNew on the source but this seemed to have no effect.



Rich Ruiz

BPM Consultant

Novanis

Avatar

Former Community Member
The data connection returns a record set. If you bind fields to it, the fields will show the values from the current record. As you go to the next/previous record the values update accordingly.



If you want to have the data from each record in set shown all at the same time, you'll need to write script that will loop through the record set and assign the values to the fields. Similar to what is done in the script for the Data Drop-down List and Data List Box objects.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Ok. I can do that but it seems like the options to repeat should do that for me.

If I make changes to the values via the fields that I populate, how do I get them back into the record set? I don't see methods to change the values.