Expand my Community achievements bar.

Dynamic xfa.form Object Reference


Former Community Member

I am trying to create a script function on a form so I can perform the same validation against multiple objects in a form. What I want to to is pass the name of the object into this function and then perform different actions against each object.

I'm happy with creating the function, passing in the values and doing what I need to against the objects but I can't work out what syntax should be there to dynamically reference each object that is passed to the function.


var sName = "xfa.form.Form.Form.sYourDetails.sFirstName.vFirstName";


var sName = "xfa.form.Form.Form.sYourDetails.sLastName.vFirstName";


function fnValidate(sName){

sName.presence = "hidden";

sName.rawValue = "XYZ";

xfa.form.Form['" + sName"'].rawValue?



Any help would be greatly appreciated.
3 Replies


Former Community Member
When in doubt about an objects name, I will put a message box out (on the enter event) with this code:


when executed it will show me the Som Expression to get access to the object. When dealing with fields in repeating subforms it is the subform that holds the fields that has the occurance number in it (not the field). So in your case the object you want is:

Form.sYourDetails[occurance number].sFirstName.vFirstName

Assuming sFirstName and VfirstName are fields.

Hope that helps


Former Community Member
try using Nodes, then you can go down a subform, and reference "everything" in it.


Former Community Member
Hi Guys,

Thanks for the responses.

I think the problem I had was that when I did CTRL Click on an object, the script showed xfa.resolvedNode instead of xfa.form.ResolveNode.

This meant I had tended to use either of the below means to reference objects in the majority of my scrips: xfa.form.Form.Form.sYourDetails.sFirstName.vFirstName


Using these I couldn't reference a specific instance or dynamically reference the objet name because I wasn't using resolveNode(s). I new I needed to us it, but it wasn't evaluating as mentioned above.

1. Why fo I need to reference the form dom in the resolveNode Expression?

2. Why wasn;t designer doing this by default?

Thanks Guys.