Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Text summary via loop through?

Avatar

Avatar
Validate 1
Level 1
TavC
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
TavC
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
TavC
Level 1

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)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
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

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
TavC
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
TavC
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
TavC
Level 1

29-11-2016

Much obliged Bruce - thank you! I do have radios in the form, but this script is great to get going with.