cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Field for AddRow function

SOLVED
Level 1

Dynamic Field for AddRow function

Hey everyone. I need help to figure out how to code a dynamic field name in a params clause. Below is the example of code.

AttTable.AddRow({
DYNAMICNAMEHERE: table.rows[0].DYNAMICNAMEHERE})

For the DYNAMICNAMEHERE I am declaring the variable value farther up in the code and referencing it as the variable name in those two sections but it isn’t working.
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Dynamic Field for AddRow function

If I understand well what you want to do, you should do something like:

var dynamicNameHere = "myCustomFieldName";
var newRow = {};
newRow[dynamicNameHere] = table.rows[0][dynamicNameHere];
AttTable.AddRow(newRow);
5 REPLIES 5

Re: Dynamic Field for AddRow function

If I understand well what you want to do, you should do something like:

var dynamicNameHere = "myCustomFieldName";
var newRow = {};
newRow[dynamicNameHere] = table.rows[0][dynamicNameHere];
AttTable.AddRow(newRow);

Re: Dynamic Field for AddRow function

Thank you for the response! How would it look if I was also adding values for known table headers in that same add row function? Would I just tack on to that string "newRow"?

Re: Dynamic Field for AddRow function

New row it's a Javascript object not a String, and yes you can add as many fields as you want :

 

var newRow = { myField1: "myFieldValue1", myField2: 12.0 };
newRow[dynamicField1] = "dynamicFieldValue1";
newRow[dynamicField2] = "dynamicFieldValue2";
newRow["thirdDynamicField"] = 10.3;

Re: Dynamic Field for AddRow function

This worked perfectly! Thank you!

Re: Dynamic Field for AddRow function

Hello - 

 

  If this solution met your needs, could you please mark the question as solved? 

 

Regards, 

-Chris Kaminski