Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Duplicating form data elsewhere in form question

Avatar

Level 4

First, I'm a newbie at this, so bear with me.

I am working on a form utilizing the javascript instance manager to add/remove name fields as needed (script found in Master-> SEC_02-> Setup_02-> Add/Remove). The instanced subform is called Name_List.

That part works fine.

Now I need to create sort of a "modified instance" of Name_List wherein information created and filled in in the above area is replicated in another part of the form. (found in Master-> SEC_02->Name_List_Copy). However, this Name_List subform is different from the first Name_List in that some objects have been removed and new ones added, so I can't simply create multiple instances in different places. But I want information input in Name_List (specifically "Name" and "DOB") to be replicated in Name_List_Copy.

I thought using a global binding would work, but when the instance manager creates more instances, the input for the first object is copied in all the others, so that won't work.

Any help in sorting this out would be appreciated.

Remember, I'm a newbie! PS. Links to any good books/tutorials specific to beginner level javascript and livecycle would be appreciated!

File attached

Graham

16 Replies

Avatar

Former Community Member

Which instance of Name_List do you want to want to copy Name and DOB from?

Avatar

Level 4

Thanks for looking into this issue.

I want to have the first instance of Name and DOB found in Master-> SEC_02-> Name_List-> Sub_List-> Sub_Name_01/Sub_DOB_01 to be the "master" entities.

Avatar

Former Community Member

The following scripts in the calculation events for Name_01 and DOB_01 in Name_List_Copy should do it.

// form1.Master.SEC_02.Name_List_Copy.Sub_Name_01::calculate - (JavaScript, client)

this.rawValue = form1.Master.SEC_02.Name_List.Sub_List.Sub_Name_01.rawValue;

// form1.Master.SEC_02.Name_List_Copy.Sub_DOB_01::calculate - (JavaScript, client)

this.rawValue =  form1.Master.SEC_02.Name_List.Sub_List.Sub_DOB_01.rawValue;

Steve

Avatar

Level 4

Thank you Steve, very succinct.

However, there is some functionality missing. Perhaps I wasn't clear in my original post.

In the first part of the form, new Name and DOB fields can be added/removed using the + and - buttons. This additional Name/DOB needs to also be replicated in the lower Name/DOB fields, which it currently does not.

Thanks!

Avatar

Former Community Member

I'm confused.

You say, "In the first part of the form, new Name and DOB fields can be added/removed using the + and - buttons. This additional Name/DOB needs to also be replicated in the lower Name/DOB fields, which it currently does not."

Yet in the original posting you stated, "...the input for the first object is copied in all the others, so that won't work."

Do you want form1.Master.SEC_02.Name_List.Sub_List.Sub_Name_01 and form1.Master.SEC_02.Name_List.Sub_List.Sub_DOB_01 values replicated in each additional instance of Sub_List AND Name_List_Copy?

Avatar

Level 4

Therein lies the confusion.

When you quote me and say, "In the first part of the form, new Name and DOB fields can be added/removed using the + and - buttons. This additional Name/DOB needs to also be replicated in the lower Name/DOB fields, which it currently does not." I will assume you have not tried adding fields using the + and - buttons. If you do, you will see that any additional subforms added will NOT be replicated in the lower form we are discussing. Excuse me for saying the same thing multiple times, but I am trying to explain this complexity and am having a time doing so!

If you add additional name fields by clicking on the + sign button, those additional fields are not added to the lower form we've been discussing to this point. They ARE added to the form which is a child of SEC_02-> sublist, but if you add additional names to SEC_02-> sublist, those additional names are not replicated in the new subform.

Gosh! It's so difficult to discuss these matters. Is that clear?

I think it'd be great if someone invented a way of easily discussing these hierarchal structures! LOL (patent, anyone) ;-)

Graham

Avatar

Level 4

Bump....

Has anyone got any ideas on how to do this?

Thanks,

Graham

Avatar

Former Community Member

Here is a modified sample of what I think you want. I moved the remove button to be inside of the subform so that th euser can remove a specific instance. I had to remove the instance in the NameListCopy before the one in the name list because of context. The code to copy the value of the name field is on the exit event of that field. You can modify it and add it to other fields in that subform as you see fit.

Paul

Avatar

Level 4

EDIT: I have added an example to illustrate the break. Note that the the Sub_Name_01 text field located in SEC_02-> Name_List has an Exit script applied to it. In Paul's original, working example, it referenced Sub_Name_01 found in Name_List_Copy which USED to be located as a subform of SEC_02. Now it is located in SEC_03 and the script no longer works.

Paul,

Sorry to get back so late on this question, but I've been trying to figure it out for myself. I'm stumped...

I know how your JS script on the Sub_Name_01 button is working, but cannot adjust the script for other uses.

Specifically, in this line:

"xfa.resolveNode("Name_List_Copy[" + this.parent.index + "]").Sub_Name_01.rawValue = this.rawValue;",

I do not understand the structure of the script. Specifically, if I make the Name_List_Copy subform a child of another subform, I lose the link to it. After resolveNode, how is JS interpreting the rest of the path >> ("Name_List_Copy[" + this.parent.index + "]") <<

I am a bit at a loss on the + signs. I haven't found adequate documentation on its use. BTW, is there some way to search for things like that? I get nothing usable when I use things like +, ++, == for search terms.

Thanks,

Graham

Avatar

Former Community Member

The resolveNode command takes astring as a reference to the object we want to address. So we are building a string to pass to the command. the + signs are javascript way of concatinating strings. So loooking at the command we are building a string to reference an obejct that looks like this:

Name_List_Copy[ this.parent.index ].Sub_Name_01.rawValue

Where this.parent.index will be replaced with the subform instance that we are on.

Hope that helps

Paul

Avatar

Level 4

Thank you, Paul, for your interest.

You have answered one question I've had. "the + signs are javascript way of concatinating strings". I have never seen it put that way, but it makes perfect sense. But this raises another question. If + signs are a way of concatinating strings, in this script

"xfa.resolveNode("Name_List_Copy[" + this.parent.index + "]").Sub_Name_01.rawValue = this.rawValue;"

Question: ...what is the purpose of the second +

Question: Does this.parent.index have to be ENCLOSED in +'s?

In the same script, I read the parts to mean:

>>("Name_List_Copy[" + this.parent.index + "]")<<is the same as saying: The Parent of Name_List_Copy (which is SEC_02)

>>.Sub_Name_01.rawValue<<   is the same as saying: has a field called Sub_Name_01

>>= this.rawValue;<< is the same as saying: which will contain the content of the original Sub_Name_01

Question: Would that be correct?

In the images below, the script you provided pertains to the hierarchy illustrated in SEC02. If you could answer the next question, I believe this would help me in understanding a lot about how the structure works.

Question: What would the script look like for SEC02-03?

Thank you very much!

Graham Calhoun

Avatar

Former Community Member

The expression you want to get is NameListCopy[instanceNumber].Sub_Name_01.rawValue

To get this we add the string "NameListCopy["

To get the instance number of the subform we use this.parent.index. (the index of the parent that holds this object).. We should get back a whole number representing the instance of the subform that contains this object.

Then we add th estring "]" to complete the expression.

Lastly we ask for the rawValue which holds the actual value of the field in question.

Hope that helps

Paul

Avatar

Level 4

I'm afraid I'm even more confused now. When you say "The expression you want to get is NameListCopy[instanceNumber].Sub_Name_01.rawValue", are you saying that the outcome of the expression will be equivalent to the above expression or are you being literal?

I really am trying to understand how this works. It's just that finding literature pertaining to the use of JS within LC is sparse.

Graham

Avatar

Level 10

There's actually a fair bit of documentation on scripting in LiveCycle and Acrobat, you have to hunt around for it though.

There are also lots of good JavaScript tutorials on the web.

LiveCycle Designer Scripting Basics:

http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics.html

LiveCycle Designer Scripting Reference 8.2 (pdf - search Google on that title if this link doesn't work):

http://www.google.ca/url?sa=t&source=web&ct=res&cd=1&url=http%3A%2F%2Fhelp.adobe.com%2Fen_US%2Flivec...

There's some good info in LiveCycle's help as well, under Scripting.

There are also pdfs around for Acrobat Javascript and FormCalc.

Hope that helps!

Note to Adobe folk - it would be nice to get all this documentation together in one spot to make it easier to find!

Avatar

Former Community Member

I am being literal. If you are in doubt as to the name of the field you can always put an app.alert(this.somExpression) on the enter event of the field. This will cause the somExpression that you want to use to be displayed to you when you enter the field in question. This would be a one time test so that you can get the value of the expression then you woudl remove that code.

Paul