These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Button to transfer user Text Field input into different Text Field

jwbrady
Registered: Sep 7 2009
Posts: 6
Answered

I am creating a form for meeting minutes. It has two flowable tables titled Old Business and New Business. I want to be able to create a button that will transfer the user input for New Business to Old Business and clear out the input for New Business. This way the next meeting the notes from the previous New Business table will be moved over to Old Business.

Example:

Minutes would be taken.

[img]http://i26.tinypic.com/23pvdv.jpg[/img]

Form would be saved and then,

[img]http://i31.tinypic.com/2uzqk9s.jpg[/img]

click on the "Button" that would move New Business to Old Business, and do a SaveAs for the next committee meeting.

---

Then I thought, maybe I could make 4 different Script buttons;

Save;
Old Business = New Business;
Rest New Business;
SaveAs;

I have the scipts down for Save, and SaveAs but I am runing into trouble with "Old=New" and "Rest New Business"

For the "Old=New" I have this in FormCalc, but this will only make the first Row equal. I'm not sure how to make this script work if I was to add another line?? I have the button down to add and remove rows but I'm not sure how to handle the information in the second and onward rows?

 form1.Sub1.CommitteeReport.Table1.Row1.Subform2.Discussion = form1.Sub1.CommitteeReport.Table2.Row1.Subform2.Discussion;
For the "Rest New Business", I have this in JavaScript, but has the same issue of just clearing the first row in New Business.

 xfa.host.resetData("xfa.form.form1.Sub1.CommitteeReport.Table2.Row1.Subform2.Discussion");
Thank you for your help.

[img]http://i27.tinypic.com/jt4gsn.jpg[/img]

My Product Information:
LiveCycle Designer, Windows
hcorbin
Registered: Aug 11 2009
Posts: 57
Hello,

You’re very close.

Here is one solution. You'll need to adapt the script to your form but this should give you an idea:

// Copy each New Business row to an Old Business rowvar nCount = Table2._Row1.countfor i = 0 upto nCount - 1 do if (i == 0) then// just copy the contents of the first row since// there is already an Old Business row in placeTable1.Row1.TextField1 = Table2.Row1.TextField2continueendif

 // Add an Old Business rowTable1._Row1.addInstance(0)// Copy the New -> OldTable1.Row1[Table1._Row1.count-1].TextField1 = Table2.Row1[i].TextField2 endfor

 // We're done copying// Remove the New Business rows, leaving one in place Table2._Row1.setInstances(1)// Reset the dataxfa.host.resetData("form1.Table2.Row1.TextField2")

Make sure both rows are allowed to repeat and the form is saved as an Adobe Dynamic XML Form.

There are a few Help topics you might find useful:

Scripting > Scripting Reference > Scripting Objects > instanceManagerScripting > Scripting Using LiveCycle Designer ES > Examples of Common Scripting Tasks > Using the instance manager to control subforms at run timeScripting > Scripting Using LiveCycle Designer ES > Examples of Common Scripting Tasks > Using the properties of the instance manager to control subformsScripting > Scripting Using LiveCycle Designer ES > Examples of Common Scripting Tasks > Using the methods of the instance manager to control subformsScripting > Scripting Using LiveCycle Designer ES > Events > List of events > indexChange eventThe last Help topic isn't useful in this scenario however you might find it useful in the future.

Hope this helps,
Hélène
jwbrady
Registered: Sep 7 2009
Posts: 6
Thank you so much for your help. I have put a ton of hours into this form and this is the last step for completion. I read over all your suggested readings and it was helpful. However, I still cannot get the code to work correctly. I changed the layout to be in subform instead of tables (thinking it would be easier). All subforms are set to flowed-western text beside P1, Sub1, Sub2 which are set to flowed-top to bottom.

I believe I'm really close with your help. Just to make sure because I don't think I said it in my original posting that the objects to be transfered from "New" to "Old" are Presentor, Topic, and Disc.

This is my Hierarchy;

[img]http://i28.tinypic.com/346uckh.jpg[/img]

From your readings and suggestions I put the following code in "F.P1.MSub1.New_to_Old::click - (JavaScript, client)"

var nCount = Sub2.ItemDetailfor i = 0 upto nCount - 1 do if (i == 0) thencontinueendif

_Sub1.ItemDetail.addInstance(0);F.P1.MSub1.Sub1.ItemDetail[Sub1._ItemDetail.count-1].Disc = F.P1.MSub1.Sub2.ItemDetail[i].Disc; endfor

 F.P1.MSub1.Sub1.ItemDetail.setInstances(1)xfa.host.restData("MSub1.Sub1.ItemDetail.desc")

This is what the layout looks like

[img]http://i32.tinypic.com/2mrxw88.jpg[/img]

This is the file that I am sharing with google docs

[url=http://docs.google.com/fileview?id=0B8kmksHZdTW3YzQ0ZWQ5OTYtYzVjNC00ODEzLWIyN2UtODhhN2Y4NTVkOWRk&hl=en]Committee Minutes - Shared[/url]
hcorbin
Registered: Aug 11 2009
Posts: 57
Good morning,

Great, the image of the Hierarchy View is very useful, thanks.

I’ve noticed a few things that should help.

1. The script language should be set to FormCalc, not JavaScript.
2. There are a few errors in the script – see comments below.

// First you want to get the number of new business items. I assume// ItemDetail is the repeating subform that represent a business item. // You can get the number of business items by getting the count property of the instance manager.// It can be done using the ‘underscore’ syntax:var nCount = Sub2._ItemDetail.count // or by using the instanceManager property of the subform://var nCount = Sub2.ItemDetail.instanceManager.count for i = 0 upto nCount - 1 do if (i == 0) then// You didn’t copy the contents of the first row, is this ok?continueendif

 // If ItemDetail is the repeating subform then I believe you should add an instance of ItemDetail, not an instance of Sub1. // Place the ‘underscore’ in front of ItemDetail instead:Sub1._ItemDetail.addInstance(0); // No Need to use the full SOM expression, just use:Sub1.ItemDetail[Sub1._ItemDetail.count-1].Disc = Sub2.ItemDetail[i].Disc; endfor

 // Same here, no need for the full SOM expression. Also, setInstances() is a method of the // instance manager, not a method of the subform:Sub1._ItemDetail.setInstances(1) // ‘Disc’ not ‘desc’xfa.host.restData("Sub1.ItemDetail.Disc")

More useful articles from the Help:

Scripting > Scripting Using LiveCycle Designer ES > Referencing Objects in Calculations and Scripts > FormCalc reference syntax shortcutsScripting > Scripting Using LiveCycle Designer ES > Referencing Objects in Calculations and Scripts > About referencing objects in calculations and scriptsAlso, while writing script, Designer can help determine the SOM expression of an object. Click in the Script Editor, then Ctrl+click the object to reference to get its relative SOM expresssion. Or, Ctrl+Shift+click the object to get its full SOM expression.

Note I couldn’t access the shared document.

Let me know how it goes,
Hélène
jwbrady
Registered: Sep 7 2009
Posts: 6
Hélène,

Thank you for your help and for your continued support. I tired the new code and got this message

[img]http://i25.tinypic.com/erelqp.jpg[/img]

then I tweaked the code to try and make it work in F.Button1::click - (FormCalc, client)

 // First you want to get the number of new business items. I assume// ItemDetail is the repeating subform that represent a business item. // You can get the number of business items by getting the count property of the instance manager.// It can be done using the ‘underscore’ syntax: var nCount = P1.MSub1.Sub2.ItemDetail.instanceManager.count// var nCount = Sub2.ItemDetail.instanceManager.count (Didn't work)// or by using the instanceManager property of the subform://var nCount = Sub2.ItemDetail.instanceManager.count var nCount = Sub2._ItemDetail.count for i = 0 upto nCount - 1 do if (i == 0) then// You didn’t copy the contents of the first row, is this ok?P1.MSub1.Sub2.ItemDetail.hd.Topic = P1.MSub1.Sub1.ItemDetail.hd.Topic;P1.MSub1.Sub2.ItemDetail.hd.Presentor = P1.MSub1.Sub1.ItemDetail.hd.Presentor;P1.MSub1.Sub2.ItemDetail.hd.addDel.Count = P1.MSub1.Sub1.ItemDetail.hd.addDel.Count;continueendif

 // If ItemDetail is the repeating subform then I believe you should add an instance of ItemDetail, not an instance of Sub1. // Place the ‘underscore’ in front of ItemDetail instead:P1.MSub1.Sub1._ItemDetail.addInstance(0); // No Need to use the full SOM expression, just use:Sub1.ItemDetail[Sub1._ItemDetail.count-1].Disc = Sub2.ItemDetail[i].Disc; endfor

 // Same here, no need for the full SOM expression. Also, setInstances() is a method of the // instance manager, not a method of the subform:// Sub1._ItemDetail.setInstances(1)(Didn't work)P1.MSub1.Sub1._ItemDetail.setInstances(1);// ‘Disc’ not ‘desc’xfa.host.restData("Sub1.ItemDetail.Disc")

but I still cannot get it to function.

Sorry for the file not being able to share before. I believe this url will share my file now.

[url]http://files.me.com/mattrobell/fdfsfv[/url]

Thanks again for your help.
hcorbin
Registered: Aug 11 2009
Posts: 57
Morning,

I made a few changes to the script. Give it a try and let me know.

var nCount = Sub2._ItemDetail.count for i = 0 upto nCount - 1 do if (i == 0) thenSub1.ItemDetail.hd.Presentor = Sub2.ItemDetail.hd.PresentorSub1.ItemDetail.hd.Topic = Sub2.ItemDetail.hd.TopicSub1.ItemDetail.Disc = Sub2.ItemDetail.Disccontinueendif

 Sub1._ItemDetail.addInstance(0) Sub1.ItemDetail[Sub1._ItemDetail.count-1].hd.Presentor = Sub2.ItemDetail[i].hd.PresentorSub1.ItemDetail[Sub1._ItemDetail.count-1].hd.Topic = Sub2.ItemDetail[i].hd.TopicSub1.ItemDetail[Sub1._ItemDetail.count-1].Disc = Sub2.ItemDetail[i].Disc endfor

 Sub2._ItemDetail.setInstances(1)xfa.host.resetData("F.P1.MSub1.Sub2.ItemDetail.Disc, F.P1.MSub1.Sub2.ItemDetail.hd.Presentor, F.P1.MSub1.Sub2.ItemDetail.hd.Topic")

What changed:

1. Fixed the first script warning by moving Button1 (the owner of the script) under MSub1. The first screen shot you provided showed the button living under MSub1
therefore I wrote the sample script to work from that location.
2. Fixed the next syntax error: should be "resetData" instead of "restData" (last line of script).
3. Fixed SOM expressions: you want to copy the contents of Sub2 into Sub1, not the other way around.
4. Added line to copy contents of Disc in the if statement and removed the copy of addDel.Count since it's a calculated field.
5. Added lines to copy contents of Topic and Presentor of remaining rows.
6. Fixed setInstances to remove the new business rows instead of the old business rows.
7. Updated the line reseting the data to reset Presentor, Topic, and Disc.

Cheers
Hélène
jwbrady
Registered: Sep 7 2009
Posts: 6
A Thousand Thanks,

This work!

[img]http://i32.tinypic.com/2nta25c.jpg[/img]