Can I reference data values of XML directly in a script or must I use a field on my form?

loather

28-01-2019

Hello, please bear with me this is my first post, sorry if I missed any forum rules or guidelines.

I have been working on a form which has a Text object that combines [concatenates] the values of 3 floating text fields.

That's all working OK but I should only print this combined value if "some other node" in the XML is null.

I was thinking to place a short script in the 'prePrint' of the first floating field [because Text objects seem to have no events] which will check if this other XML node is null or not. If null, it would set the 'relevant = "+print"' property of the Text object itself, else it would set 'relevant = "-print"'.

1] Is this a correct approach please?

2] Can I reference a value from the XML source data in the script? [something like "if $.node1.node2 is null"] or do I have to create some hidden/non-printing field on my form to capture the value from the XML, and then my script references the value of this hidden field?

Many thanks in advance.

View Entire Topic

altrue990

29-01-2019

You are correct, the XML DOM is only accessible by binding form objects to it. You approach seems solid. It has been a long time since I've used prePrint events, but I remember them to be a bit unwieldy. If the data is static (i.e. it is part incoming XML rather than entered by the user on the form), then try to override the initialize event instead. It should accomplish the same effect.