cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

cannot read data via javascript / data node is empty

0 Likes
2,460

Hi,

i try to create a print form with Adobe Forms. The job is nearly done, but now i have to do following:

Depending on some data (which is not bound via data binding) i'd like to do some formatting (background color, font ...).

For this purpose i have inserted a javascript to the initialize-event:

this.rawValue = xfa.resolveNode("xfa.datasets.data.MY_FIELD").value;

But i get no data. The MY_FIELD node is not found.

After trying resolveNode with various paths, i tried

this.rawValue = xfa.resolveNode("xfa.datasets.data").saveXML();

Result:

<?xml version="1.0" encoding="UTF-8"?>

<xfa:data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />

The data node is empty. But why???

Data binding works. The data is passed to the form completely. I just cannot read it via script.

I don't want to use data binding with invisible fields and then read the field values, because i need this also in a table. Using invisible fields in table is not a good idea, because you cannot make table cells invisible without getting "holes" in your table

Any help appreciated!

Peter Herweg

View Entire Topic
NoJo
Active Participant
0 Likes

Hi,

solution in Javascript

if you want to access the value of a field you can use two (perhps more?) ways.

Via the DATA node --> var myVar = xfa.resolveNode("xfa.record.MY_FIELD").rawValue or .value, depends on your type

Via the hierarchy node -->

var myVar = xfa.resolveNode("data.Page1.subform1.MY_FIELD").rawValue

But you can try this: if your cursor is positioned in the script editor for example after "var myVar = " hold the control (="Strg"?) button on your panel an go with the cursor to the relevant field --> a "V" will appear --> now do a left mouse click and the correct SOM expression will be copied to your script. You will just have to add "rawValue" or "Value"

for tables it's a little bit different...

tell me if it worked, please

br

norbert