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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Dynamically populating a text field on the Master Page

JLAFARGUE-FMiGI
Level 3
Level 3

I'm trying to populate a text field on the Master Page of a form by having it populate as a user types data into a text field in a content area.  So far, I have it populating when the user puts the cursor into the Master Page text field and then leaves that field after typing data in the text field in the content area.  I want the text field in the Master Page to populate as the user types in the text field in the content area, so it looks like both fields are being filled simultaneously.

The script which now populates the text field in the Master Page is

this.rawValue = MNPD.Form130.Page1.CSIInfo.CPN.rawValue;

This script is in the Enter, Exit, Calculate and Validate events of the Master Page text field.

I suspect that I am not correctly referencing the Master Page text field when trying to put a script in the content area text field events.

From the Hierarchy, the Master Page text field is   MNPD > Master Pages > PageArea1 > CPN and the text field in the content area is

MNPD > Form130 > Page1 > CSIInfo > CPN

I have tried putting the following scripts in the exit event of MNPD>Form130>Page1>CSIInfo>CPN and they have all failed:

MNPD.#pageSet[0].PageArea1.CPN.rawValue = this.rawValue;

MNPD.pageSet[0].PageArea1.CPN.rawValue = this.rawValue;

MNPD.pageSet.PageArea1.CPN.rawValue = this.rawValue;

I even tried renaming Master Pages to MasterPages and replacing pageSet with MasterPages and that didn' t work.

How does one do this?

0 Replies
radzmar
Level 10
Level 10

I'm not sure I understood what your're trying to do.

But if you would like to update another fields value while typing you can use this script in the change:Event of the field you're typing in.

JLAFARGUE-FMiGI
Level 3
Level 3

I'm trying to change the raw value in text field in my Master Page either as the user types in a text field on the form or as the user exits the field in which he typed data.

I know that I have to set the raw value of the text field in my Master Page to the raw value of the text field in which my user is typing. My problem is that I don't know how to refer to the text field in my Master Page by its fully qualified name. I can say 'this' when I'm in the Master Page text field scripts, but I don't know how to refer to that field when I'm in a script of one of the pages.

radzmar
Level 10
Level 10

You can read the full som expression of a field it the script editor.

Go to the master page and select your text field.

Then open the script editor and select any available script.

The first line in the script editor show the som expression such as

form1.#pageSet[0].Page1.TextField2::exit - (JavaScript, client)

To refer to the field use xfa.resolveNode("form1.#pageSet[0].Page1.TextField2").rawValue

JLAFARGUE-FMiGI
Level 3
Level 3

ARRRRGHHHH!! I knew where som expression was. I just didn't know how to use it. The resolveNode method was what I was missing. I tried it. I now sit here (after typing this) with two fists thrust in the air in VICTORY. !!

Don400
Level 3
Level 3

It seems that the master page's objects are not instantiated until after the page is initialized.  I tried referencing the #pageSet[0] in an initialize method and got null but in the form::docReady method it worked.  Is there a reason for this?

JLAFARGUE-FMiGI
Level 3
Level 3

I don't know the reason. I'm sure there is one. I'm finding LiveCycle and Javascript a bit inscrutable these days, being inexperienced at both. Anyway, putting the necessary code in the docReady event worked. It's maddening how the solution was so simple, and I was so close, but still so wrong. Now if someone would show me how to add an instance to a subform but have it appear in the middle of the array.....

djaknow
Level 7
Level 7

To have an instance appear somewhere other than the bottom when added, you can use the moveInstance function, i.e. -

_row1.addInstance(true);

_row1.moveInstance((_row1.count-1), newIndexPosition);

where _row1.count-1 is the newly added row and newIndexPosition is where you want the new row to end up.

JLAFARGUE-FMiGI
Level 3
Level 3

What happens to the instance that was formerly occupying the position marked by newIndexPosition and all the other instances between newIndexPostion and the (new) last instance?

JLAFARGUE-FMiGI
Level 3
Level 3

I got it to work with one little hitch. The moveInstance method moved the instance to the position after the one designated by newIndexPostion. That's what I wanted so I just let the index of the current instance be the second parameter. I knew it would be simple. Thanks.

Here's the code from the click event:

// Save the current instance index and location

var i = this.parent.index;

var MyLocation = this.somExpression;

// Add the new instance

parent.instanceManager.addInstance(1);

// select the instance to be relocated (in this case, it's the one just added)

var last = this.parent.instanceManager.count - 1;

// Move the new instance to the desired position after the current instance

parent.instanceManager.moveInstance(last, i);

// Set the cursor position for when the screen is redrawn.

xfa.host.setFocus(MyLocation);

djaknow
Level 7
Level 7

Just as an fyi, I think the index # is zero based while the count is not, which might explain why it would move one position down from where you expected?

JLAFARGUE-FMiGI
Level 3
Level 3

Indexes are zero-based, but the second parameter of the moveInstance method appears to point to the instance BEFORE which the source instance will be moved. Thus, if you have a five-instance subform, and you want to move the last instance to the third position, the parameters you must pass should evaluate to 4 and 2 respectively.

djaknow
Level 7
Level 7

That's it exactly, is that not what you were expecting? I'm confused lol

JLAFARGUE-FMiGI
Level 3
Level 3

It is now. I expected that the second parameter of moveInstance indicated the position to where the instance would be moved, not the position before the target. When I used it that way, moveInstance put the instance two places ahead of the current instance. Anyway, I've got it working. Thanks.

Apemancity
Level 2
Level 2

I was trying to created a dymanic form number but we I click the field changes for but flashes back to the default state.


When I place the code on a button that doesnt force a reflow it works.

But as soon as the form reflow the field resets.

Any ideas?

Also I have a dymanic title bar breaking over 2 pages one the first page the title changes but it doesn't change on the 2 page.

Thanks

Apemancity
Level 2
Level 2

So i solved my own problem. Instead of having the coding run on the button, I moved it to field thats changing and used the calulate event and that works.

erik_crl
Level 2
Level 2

Hello,

I came across this post as help. Though, I seem to be having issues with my javascript or placement of my script.

I wonder if you can detail what you did.

My scenario is:

In design view, I place the following script in change::event -> xfa.resolveNode("form1.#pageSet[0].StudyPLan.TextField").rawValue=this.rawValue;

The intent is to have the text that is entered into "this" field to echoed in the "StudyPLan.TextField" on the master page. (Note that the Textfield on the master page is a Floating field. Do I really need that or can it be left as a standar text field?).

Ideally, I will want the value from "this" to be echoed to pages 2 and so on as the document is populated.

Thanks,

Erik

erik_crl
Level 2
Level 2

Found an alternative answer to reach my goal.

From AcrobatUbsers (https://answers.acrobatusers.com/Live-cycle-8-2-Linking-fields-master-page-q7360.aspx)

I used the Binding feature within the Object properties.

Erik

andreil35595428
Level 1
Level 1

Hello!

I have a similar situation and I don't know how to handle it.

There is a field in the master page which I want to appear on bottom of each page.

In the normal page I have a repeating Subform which can flow on multiple pages and it contains multiple fields.

Scope: In the field from the master page I want to display the last value of a field from the current page.

Example:

Page1 has only one item 0010 -> field from master page on the first page = 0010

Page2 has two items 0020 and 0030 -> field from master page on the second page = 0030

Page3 has three items 0040, 0050 and 0060 -> field from master page on the third page = 0060

...and so on

What I've tried without success:

1.Created a global variable in interface and a text field on the master page with binding set as Use Global Data

2. In the event indexChange of the repeating Subform I have the following JavaScript:

     $record.<name of the global text field>.value = Subform.Field.rawValue

Global field assignment works fine, but it contains the last value from the binded table on each page. From the above example: 0060 on each page.

_Bruce_Robertson
Level 10
Level 10

Hi,

I think you will need a script in the layout:ready event of the field on the Master Page, something like;

var result

var page = xfa.layout.page(this)

var rows = form1.Page1.Table1.resolveNodes("Row1[*]");

for (var i = 0; i < rows.length; i++) {

    var row = rows.item(i);

    if (xfa.layout.page(row) > page) {

        break;

    }

    result = row.resolveNode("TextField1").rawValue;

}

this.rawValue = result;

This script will assign the last value of TextField1 on the same page as the current master page occurrence of the field with the script.  So you will need to change form1.Page1.Table1.TextField1 to match your form.

Regards

Bruce