Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Dynamically add data to a table field from a drop-down?

Avatar

Level 2

Hi,

I have been trying to create a drop-down to dynamically populate a table based on what drop-down option is chosen. I can get it to work for adding a row at a time, which is fine, but I want to add text related to the chosen option to a field in the newly created row. I can get this to work using Row1.Field.rawValue = "blah blah blah" but when I want to get dynamic and call the row being created by using something like resolveNode I can't get anything to be entered into the field. Can this be done at all?

Here is my script:

==================

topmostSubform.Page1.tabletest.DropDownList2::exit - (JavaScript, client)

if (this.rawValue == 1) {

  Table4._Row1.addInstance()

  Page1.tabletest.Table4.Row1.Identity.rawValue = "Easement for Transmission Line"

  };

if (this.rawValue == 2) {

Table4._Row1.addInstance()

Page1.tabletest.Table4.resolveNode(Row1[Table4.Row1.instanceManager.count-1]).Identity.rawValue = "Easement for electricity and other purposes"

xfa.host.messageBox("Ausgrid");

};

===================

The first part, for this.rawValue == 1 works okay for one instance of adding. The second part, where I have tried to do a resolveNode, adds a row but does not enter any text.

Thanks in advance for your help with, and consideration of, this problem.

Cheers,

Greig

poulate_table_dynamically_from_drop_down.jpg

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

the resolveNode method needs somExpressions wrapped in quotes.

In opposite to FormCalc JavaScript doesn't support the numeric values in the accessors [] to resolve an specific instance.

Change your script into;

Page1.tabletest.Table4.resolveNode("Row1[" + Table4.Row1.instanceManager.count-1 + "]").Identity.rawValue = ...

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

the resolveNode method needs somExpressions wrapped in quotes.

In opposite to FormCalc JavaScript doesn't support the numeric values in the accessors [] to resolve an specific instance.

Change your script into;

Page1.tabletest.Table4.resolveNode("Row1[" + Table4.Row1.instanceManager.count-1 + "]").Identity.rawValue = ...

Avatar

Level 2

Thanks very much for the reply, which is absolutely correct. I did manage to find the answer in the assure Dynamics blog - http://www.assuredynamics.com/index.php/2011/05/som-expressions/, which has a nice dynamic demonstration that was very helpful.