Assigning values to a dynamically created infotable
Hi, hoping someone can help with with an issue I'm struggling with? I'm tying to create a dynamic monthly sales table. something like the one shown below.
| Product | Feb | March | April | May | June | July |
| AX 500 | 100 | 80 | 120 | 80 | 100 | 50 |
| PQ 500 | 50 | 60 | 65 | 65 | 80 | 80 |
| AX250 | 100 | 87 | 60 | 70 | 60 | 75 |
I am using a dynamic infotable as I allow the user to select the number of months they wish to display, so there could be 1 month or 20 months. I am able to dynamically create the infotable to return from my service by creating an empty infotable and then adding the required fields (months) using the code shown below:
var params = { infoTableName: "tmpTable" /* STRING */};
var myTable = Resources["InfoTableFunctions"].CreateInfoTable(params); // myTable: INFOTABLE
var newField = new Object();
newField.name = "Product"
newField.baseType = 'STRING';
myTable.AddField(newField);
newField.name = "Feb"
newField.baseType = 'INTEGER"
myTable.AddField(newField);
newField.name = "March"
newField.baseType = 'INTEGER';
myTable.AddField(newField);
and so on.
My problem arises when I want to add a row for each of the products. Normally with a pre-defined datashape I could use something likethe below to assign values to each column
var newEntry = new Object();
newEntry.Product = "AX500" // STRING
newEntry.Feb = 100 ; //INTEGER
newEntry.March = 60 ; //INTEGER
myTable.AddRow(newEntry);
How can I do this with a dynamic field which I have no prior knowledge of?
Can I index the fields as an array in some way?
Thanks
K

