Text summary via loop through?

TavC 27-11-2016

Hi,

I'm trying to generate a text summary field at the end of a form. The form has many sections which could be shown, hidden, or duplicated so I assume the best way is to do a loop through of all the visible form objects - rather than telling the summary field to get field values at defined locations, tell it to go look for what's there and report back.

The summary format is "caption = value; caption = value;" etc

It could run on a button click, though to prevent differences between the field value and the summary value, ideally this would run live, e.g. on the calculate event of the summary field.

Any help gratefully received!

Accepted Solutions (1)

Accepted Solutions (1)

BR001
MVP
29-11-2016

Hi,

Maybe this code will get you started, it goes though your form page by page, then every field on the page and displays an alert of the field caption and value for each field that is visible.

function isNodeVisible(node) {

    for (; node.somExpression !== "xfa[0].form[0]"; node = node.parent) {

        if (node.presence == "hidden" || node.presence == "invisible") {

            return false;

        }

    }

    return true

}

for (var i = 0; i < xfa.host.numPages; i++) {

    var fields = xfa.layout.pageContent(i, "field");

    for (var j = 0; j < fields.length; j++) {

        if (isNodeVisible(fields.item(j))) {

            if (fields.item(j).ui.oneOfChild.className != "button") {

                app.alert(fields.item(j).caption.value.text.value + " " + fields.item(j).rawValue);

            }

        }

    }

}

You will need to do some more work to get the caption if you have any radio buttons

Regards

Bruce