Expand my Community achievements bar.

SOLVED

Copy Completed Subform

Avatar

Former Community Member

Is there a way I can use a DropDown List to allow a user to copy a completed subform and then edit the new subform. I do not want to set the fields to Global Data as this will then change every field that is the same.

The user may only want to change 20% of the information that is why I thought it would be easier to copy the complete subform and then they can amend the required fields.

Any suggestions would be appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

There is a lot to consider in da loop, I don't really know what is in your form... making a loop in the xdp file needs specification on what you are searching for.. you will have to use a recursive method like this getNodes(rootNode);

you must verify if the object is a field to get it's value:

rootNode.className = "field"

you must verify if the object is a radio button list to get it's value:

rootNode.className = "exclGroup"

and you must verify that the field is not a button:

rootNode.isPropertySpecified("ui") <-- this object MAY be a button if it returns true

rootNode.ui.nodes.item(0).className = "button" <--ONLY IF ui property is specified or else it creates an error

to make sure you are not getting lost in your loop you can send two different nodes in your recursive method:

getNodes(rootNode, destinationNode);

and re-call the method like this:

if (rootNode.nodes.length > 0){    

for (var i = 0; i < rootNode.nodes.length; i++){

getNodes(rootNode.nodes.item(i), destinationNode.nodes.item(i)); <-- this way destinationNode and rootNode will always be the same IF both                                                                                                                                  destination and root are the same form but different instance

                                        }

}

View solution in original post

5 Replies

Avatar

Level 10

You would need to add an instance to that subform and then just send the values to the new subform's object instances

Avatar

Former Community Member

Hi Robert,

Thank you for the answer, how would I send the values?

Thanks

Avatar

Level 10

FormInstance[1].txtField1.rawValue = FormInstance[0].txtField1.rawValue;

or

FormInstance[_FormInstance.count - 1].txtField1.rawValue = FormInstance[0].txtField1.rawValue;

do it for each fields, if u have a dynamic table it's the same idea.. if you dont want to do it for each field

you can have a loop that gets every values in one form and send the values directly to the same field

Avatar

Former Community Member

How would I do a loop that gets every value in one form and sends directly to the other form.

Thank you

Avatar

Correct answer by
Level 10

There is a lot to consider in da loop, I don't really know what is in your form... making a loop in the xdp file needs specification on what you are searching for.. you will have to use a recursive method like this getNodes(rootNode);

you must verify if the object is a field to get it's value:

rootNode.className = "field"

you must verify if the object is a radio button list to get it's value:

rootNode.className = "exclGroup"

and you must verify that the field is not a button:

rootNode.isPropertySpecified("ui") <-- this object MAY be a button if it returns true

rootNode.ui.nodes.item(0).className = "button" <--ONLY IF ui property is specified or else it creates an error

to make sure you are not getting lost in your loop you can send two different nodes in your recursive method:

getNodes(rootNode, destinationNode);

and re-call the method like this:

if (rootNode.nodes.length > 0){    

for (var i = 0; i < rootNode.nodes.length; i++){

getNodes(rootNode.nodes.item(i), destinationNode.nodes.item(i)); <-- this way destinationNode and rootNode will always be the same IF both                                                                                                                                  destination and root are the same form but different instance

                                        }

}