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

SOLVED

How to identify the last instance of a dynamic table row

a_c_hoff
Level 3
Level 3

Hi all,

I am trying to figure out how to create an action for my form in Livecycle Designer ES2 that will affect the most recent instance of a dynamic table row. I have a table with a repeatable row where the user will enter information about a purchased part and I have buttons that allow the user to add and remove rows. I need to create an additional add row button that will add a new instance of the repeatable table row (this is not an issue) and will disable and change the background color of the first cell in the added row. The problem I am having is how to have an action that affects the last instance of a row.

If anyone knows how to do this in Javascript I would appreciate some advice/help.

1 Accepted Solution
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I think this is beyond what an action will provide. You will a have to write some JavaScript directly.  When you call the addInstance method it returns the new row, so you can do something like;

var row = Table1._Row1.addInstance();

row.TextField1.border.fill.color.value = "255,0,0";

row.TextField1.access = "protected";

To find the last row and do the same thing you can do something like;

var row = Table1.resolveNode("Row1[" + (Table1._Row1.count - 1) + "]");

row.TextField1.border.fill.color.value = "255,0,0";

row.TextField1.access = "protected";


Regards

Bruce

View solution in original post

6 Replies
_Bruce_Robertson
Correct answer by
Level 10
Level 10

Hi,

I think this is beyond what an action will provide. You will a have to write some JavaScript directly.  When you call the addInstance method it returns the new row, so you can do something like;

var row = Table1._Row1.addInstance();

row.TextField1.border.fill.color.value = "255,0,0";

row.TextField1.access = "protected";

To find the last row and do the same thing you can do something like;

var row = Table1.resolveNode("Row1[" + (Table1._Row1.count - 1) + "]");

row.TextField1.border.fill.color.value = "255,0,0";

row.TextField1.access = "protected";


Regards

Bruce

View solution in original post

IanFlem
Level 2
Level 2

Hi 

I have a similar problem I need to resolve. I my case have a field called ContactP, which is placed in Row1 of a Table called ContacT which is placed in a repeating subForm called AddContact.  I need to get the value of ContactP in last instance of the repeating subForm. Any suggestions how to do this.

Magus069
Level 10
Level 10

Hey there,

 

technically it's the same process as Bruce mentioned above. Simply use the resolveNode method to access the desired repeated subform by calling its count property by using the instanceManager with one of these ways:

_AddContact.count - 1
//or
AddContact.instanceManager.count - 1

//result
PageName.resolveNode("AddContact[" + (PageName._AddContact.count - 1) + "].ContactT.Row1.ContactP.rawValue");

In the case that you have to specify which instance of Row1, you would have to add an additional resolveNode or additional xPath for it to access the instance desired

 

I hope this will help.

adeivasigamani
Level 4
Level 4

The table in Desinger has rows based on index starting from 0, so as Bruce has advised, you can get the count of the rows and count - 1 will give you the latest added row instance index, which can be used to manipulate the row.

var rowCount = Table.Row.count;

Table.Row[count-1].textField.access = "";

Regards -

Ashok D

a_c_hoff
Level 3
Level 3

Thank you for your help. I have had to learn Javascript myself, so I am not as proficient as I could be. I knew that it should be possible to use count - 1 to specify the last row instance, but I didn't think (or know how) to use a variable to define this. Thank you for your help.