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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Dynamic Field for AddRow function

ptc-6292144
3-Visitor

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

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);

View solution in original post

5 REPLIES 5

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);

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"?

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;

This worked perfectly! Thank you!

ckaminski
13-Aquamarine
(To:ptc-6292144)

Hello - 

 

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

 

Regards, 

-Chris Kaminski 

Top Tags