Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

scripting - cannot access textfield if its value is empty

Avatar

Level 1

I'd like to perform some operations on textfields' values.

I cannot do these if the value of these is empty.

To clarify, I have a textfields with binding pointing to xml data.

So in binding I have somthing like $.root.branch.element.

And xml like

<root><branch><element>value</element></branch></root>

If value is set and I perform script:

xfa.host.messageBox(xfa.resolveNode('page.table.row.TxtElement').rawValue);

I get the Message with the value.

If XML is set like this instead:

<root><branch><element></element></branch></root>

when I perform script:

xfa.host.messageBox(xfa.resolveNode('page.table.row.TxtElement').rawValue);

nothing happens. No message.

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can add a check for null values, to make this work.

var oField = xfa.resolveNode('page.table.row.TxtElement');
if (oField.isNull) {
    xfa.host.messageBox("The field is empty");
} else {
    xfa.host.messageBox(oField.rawValue);
}

 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

You can add a check for null values, to make this work.

var oField = xfa.resolveNode('page.table.row.TxtElement');
if (oField.isNull) {
    xfa.host.messageBox("The field is empty");
} else {
    xfa.host.messageBox(oField.rawValue);
}