Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to reference to the raw value of a text box entered in a new row

Avatar

Former Community Member

Hello,

I have a livecycle form with a text box and radio buttons.

There is another section of the form which shows the raw value of the text box when the radio button is clicked.

The formcalc script works correctly for the first row.

if (xfa.form.form1[0].AgendaMatrixFrame[0].AgendaMatrixRow[0].AgendaRadios[0].ActionRadio[0] == 1) then

xfa.form.form1.AgendaMatrixFrame.AgendaMatrixRow.AgendaItem.rawValue

else

""

endif

There is another button when pressed will add a new row to the form.  This javascript works correctly.

form1.CommonScripts.AddRow();

I have not been sucessful in retrieving the raw value of the text box if a new row is added.

I changed the reference in the script from AgendaMaxtrixRow[0] to AgendaMatrixRow[1] but there was an error.

Can anyone please provide assistance with how to correctly reference to the new row when added?

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You syntax is out a slight bit:

This...

this.rawValue = oLastRow.AgendaItem.rawValue; newLine 

...should read...


this.rawValue = oLastRow.AgendaItem.rawValue + newLine;

I have uploaded an example that uses a listbox to populate the relevant items from the table. It might give you some ideas.

https://acrobat.com/#d=Mqi3LEjLZv1iWtoIbhZJ8w

Good luck,

Niall

View solution in original post

6 Replies

Avatar

Level 10

Hi,

It looks like the addInstance script is in a script object (CommonScripts), so it is difficult to see the repeating object. I am assuming that it is AgendaMatrixRow.

In your if statement you are providing the full SOM expression for the ActionRadio test, but not for the assignment of the AgendaItem value. Presumably this is in the calculate event of another object:

if (xfa.form.form1[0].AgendaMatrixFrame[0].AgendaMatrixRow[1].AgendaRadios[0].ActionRadio[0] == 1) then

     $ = xfa.form.form1[0].AgendaMatrixFrame[0].AgendaMatrixRow[1].AgendaItem[0]

else

     ""

endif

This approach is not going to be dynamic, as it is set at design time to look at the second instance only. Therefore when the form is opened you will get an error and the script will only work when the user clicks to add another row. If this is what you are looking for, then fine, but you may want something more dynamic.

Hope that helps,

Niall

PS: I suspect that you want to reference the value of AgendaItem for the last row. If this is the case then the following should work in the calculate event. I am using Javascript fere:

var i = AgendaMatrixFrame._AgendaMatrixRow.count - 1; // the underscore _ is shorthand for instanceManager

var oLastRow = xfa.resolveNode("AgendaMatrixFrame.AgendaMatrixRow[" + i + "]"); // resolve the last row and assign to a variable

if (oLastRow.AgendaRadios.AgendaRadio.rawValue == 1)

{

     this.rawValue = oLastRow.AgendaItem.rawValue;

}

else

{

     // other script

}

This will also look at the last row in the table.

Note 'count' is based on starting at 1, whereas the instance number is zero-based. Thats why we subtract 1 when declaring oLastRow.

Avatar

Former Community Member

Thank you very much for your help.

Thank you for your help.  I have used the dynamic java script which works fine.

The script will list the last row, however when a new row is added, the existing row gets over written.

I have added a variable for a carriage return, and now the script puts a line feed without the raw value.

Can you please advise how the script can be amended to list all items associated with the radio button when they are added?

var i = AgendaMatrixFrame._AgendaMatrixRow.count - 1; // the underscore _ is shorthand for instanceManager

var oLastRow = xfa.resolveNode("AgendaMatrixFrame.AgendaMatrixRow[" + i + "]"); // resolve the last row and assign to a variable

var newLine = "\n\n";

if (oLastRow.AgendaRadios.ActionRadio.rawValue == 1)

{

this.rawValue = oLastRow.AgendaItem.rawValue; newLine  

}

else

{

""

}

Many thanks for your assistance.

Avatar

Correct answer by
Level 10

Hi,

You syntax is out a slight bit:

This...

this.rawValue = oLastRow.AgendaItem.rawValue; newLine 

...should read...


this.rawValue = oLastRow.AgendaItem.rawValue + newLine;

I have uploaded an example that uses a listbox to populate the relevant items from the table. It might give you some ideas.

https://acrobat.com/#d=Mqi3LEjLZv1iWtoIbhZJ8w

Good luck,

Niall

Avatar

Former Community Member

Thank you very much for all your help, it has been greatly appreciated.

I have been able to successfully add the raw value for new rows.

I changed the text box to a list box as guided by your example for this to work.

var vRows = xfa.form.form1.AgendaMatrixFrame._AgendaMatrixRow.count; // look at number of rows

var vCurrentRow;

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.rawValue = null;

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.clearItems();

for (var i=0; i<vRows; i++) // look at each row in turn

{

vCurrentRow = xfa.resolveNode("xfa.form.form1.AgendaMatrixFrame.AgendaMatrixRow[" + i + "]");

if (vCurrentRow.AgendaRadios.ActionRadio.rawValue == 1)

{

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.addItem(vCurrentRow.AgendaItem.rawValue);

}

Last question:

Is it possible to have the list box expand for each row similar to a multiline text box?

Thanks very much.

Avatar

Level 10

Hi,

Glad you got it working. I suppose one word of caution. Just make sure the listbox will serve your purpose. If it is likely to be longer than one page, you may have difficulties as it will not split and span multiple pages.

If you look at the script in the prePrint event of the listbox, you will see script that was posted by Steve Walker in a different thread. This expands the height of the listbox before the document prints and then there is script in the postPrint event to shrink it back down.

You could use this script every time a row is added.

Good luck,

Niall

Avatar

Former Community Member

Thank you for your assistance, the form is adding rows and placing the raw value in a list box and the height is increased.

var vRows = xfa.form.form1.AgendaMatrixFrame._AgendaMatrixRow.count; // look at number of rows

var vCurrentRow;

var vLength = this.length;// increases the height

var h_ = 45 + ((vLength - 6)*5);

h_ = h_.toString() + "mm";

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.rawValue = null;

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.clearItems();

for (var i=0; i<vRows; i++) // look at each row in turn

{

vCurrentRow = xfa.resolveNode("xfa.form.form1.AgendaMatrixFrame.AgendaMatrixRow[" + i + "]");

if (vCurrentRow.AgendaRadios.ActionRadio.rawValue == 1) // equal to Yes if radio button is clicked

{

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.addItem(vCurrentRow.AgendaItem.rawValue); // add the raw value to a list box

xfa.form.form1.ActionsAgendaFrame.ActionsAgenda.h = h_; // increase the height of the list box

}

}

thanks once again, your help  and advice has been most appreciated.