cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting: address table fields

Former Member
0 Kudos

Hi Form gurus,

I've got a form with a table with two columns, "value1" and "value2". Then, I've got a button that should copy all values from column "value1" to the column "value2".

The data hierachy looks like this:

[page1] 
     | 
     |--[table] 
        | 
        |--[row] 
              | 
              |---value1 
              |---value2 

When I click the button, a script has to be executed, that copies the values. I tried the following script:


for (i=0;i<page1.table.row.all.length ;i++) 
{ 
page1.table.row.value2<i>.rawValue=page1.table.row.value1<i>.rawValue 
} 

Unfortunately, nothing happens.

When I script

page1.table.row.value2.rawValue=page1.table.row.value1.rawValue

only the first row is copied.

Do you know how I have to address the repeated fields in the table?

Thx, Karsten

Accepted Solutions (1)

Accepted Solutions (1)

markus_meisl
Active Contributor
0 Kudos

Hi Karsten

I'm afraid I cannot resolve your issue, but I can suggest that you use FormCalc instead of JavaScript for your table.

If you look for Accessors in the Designer documentation, you should find information on how to access repeating fields.

Kind regards,

Markus Meisl

SAP NetWeaver Product Management

Former Member
0 Kudos

Hi Markus,

of course I've read the Adobe help, but it didn't help.

Due to the lack of loops in FormCalc I'm not sure how to solve this without JavaScript.

Regards, Karsten

Former Member
0 Kudos

Maybe I am not understanding your problem right, but I'va done some a little like this using subforms, indeed in Formcalc with a loop.

$ = 0

for int=0 upto $record.HOURLIST.nodes.length-1 step 1 do

$ = $ + data.#subform[0].Subform1.Subform2[int].UZo

endfor

$ stands for this, but could be replaced by anything else.

Hope this helps and regards, Hans

Former Member
0 Kudos

Hi Karsten,

to access fields in JavaScript you have to use the

resolveNode function.

Example:

xfa.resolveNode("EmployeeInfo.page1.table.row["i"].container.Name").rawValue=...;

Best regards

Juergen Hauser

Adobe Systems

Former Member
0 Kudos

Thanks Jürgen,

that did the trick. I don't exactly know why, so if you could drop some addtional sentences

BR, Karsten

Former Member
0 Kudos

Karten, Jurgen,

Maybe an incredible stupid question, but what kind of tables do you mean in this topic? Do you mean array like structures in the context?

I do not expect a complete answer, but a point where to look further would be great.

Thanks in advance, Hans

Former Member
0 Kudos

Hi Karsten,

you have to use resolveNode when you want to access an object which is specified by a SOM expression. resolveNode returns a handle to the object and then you can access properties or call methods.

In your example you had a SOM expression pointing to an object.

Regards

Juergen

Former Member
0 Kudos

Hi Hans,

tables are used to view data this is contained in a repeated data nodes.

In this case we had an array of rows where each row contains a separate data structure.

Do you mean the data view in Designer with "context"?

Regards

Juergen

Former Member
0 Kudos

Hello Juergen,

Yes, I meant the Data View.

Strange thing is that until now I never felt the need to use tables, but could do with repeating subforms, which problably are a kind of subclass form the table you meant (I see now).

Best regards, Hans

Former Member
0 Kudos

Hello Hans,

tables are based on subforms. But they add more functionality like support for accessibility.

So you should try to go with tables if possible.

Best regards

Juergen

Former Member
0 Kudos

Hi Juergen,

I saw this topic and I am facing a similar problem. I hope you can help me

The functionality I want is the following. I have a R/3 table binded to my IF form

via context. I know this is a XML schema.

The table name = TABMATNR1, and it has the structure DATA and underneath that stucture 3 simple fields MATNR,MAKTX,KWMENG.

Now I want to fill a dropdownbox with javascripting. I have managed to create an object reference to a node but the functionality is not correct.

I hope you can advise me what todo.

Here is my coding:

<b>var oItems = xfa.resolveNode("xfa.record.TABMATNR1.DATA");

var nItemsLength = oItems.nodes.length;

for (var nItemCount = 0; nItemCount < nItemsLength; nItemCount++) {

dropdown.addItem(oItems.nodes.item(nItemCount).value);

}</b>

The result is that I get the three values of the first record of my table TABMATNR1

in my dropdownbox. I think it has todo with my reference object, it should not

be a record reference but a table reference.

For example I only want to populate the MATNR values of TABLEMATNR.DATA[*].MATNR into my dropdown box.

I hope you can help me!!

Regards Harrie

Answers (0)