Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
I have an INFOTABLE, with Column Names RT-1, RT-3, RT-2.
Issue 1: Client want the Order of the Fields/Columns to be RT-1, RT-2, RT-3.
Issue 2:
var oldEntry = new Object();
oldEntry.RT-1= startDate; //ERROR, SINCE RT-1 has "-" in the middle.
Thanks !!
Solved! Go to Solution.
Due to Pivot the Columns order got Changed, Since my datashape as Field name in order, I have Created an Datashape based empty INFOTABLE, then I merged it with the INFOTABLE who columns were not in Order, That solved my Issue.
//Create INFOTABLE based on DataShape
var params_forOrder = {
infoTableName : "InfoTable",
dataShapeName : "datashapeName" //Since DataShape has the Value Fields in Order, new Table will be in Ordered Columns
};
var table2 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params_forOrder);
table2.AddField({ name: "timestamp", baseType: "DATETIME" });
//table1 has unordered table
var params_Merge = {
t1: table2, // Empty INFOTABLE
t2: table1 // Unordered INFOTABLE
};
// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Union(params_Merge);
I created a infotable with column name RT-1, RT-2, RT-3 and I am able to add values for all the columns. I used below code,
var params = {
infoTableName: "TestInfoTable" /* STRING */
};
//result: INFOTABLE
var result = Resources["InfoTableFunctions"].CreateInfoTable(params);
var newField;
newField = new Object();
newField.name = "RT-1";
newField.baseType = 'STRING';
result.AddField(newField);
newField = new Object();
newField.name = "RT-2";
newField.baseType = 'STRING';
result.AddField(newField);
newField = new Object();
newField.name = "RT-3";
newField.baseType = 'STRING';
result.AddField(newField);
var newEntry = new Object();
newEntry["RT-1"] = "StartDate";
newEntry["RT-2"] = "Date";
newEntry["RT-3"] = "EndDate";
result.AddRow(newEntry);
Please check if above mentioned helps you achieve your use case.
Due to Pivot the Columns order got Changed, Since my datashape as Field name in order, I have Created an Datashape based empty INFOTABLE, then I merged it with the INFOTABLE who columns were not in Order, That solved my Issue.
//Create INFOTABLE based on DataShape
var params_forOrder = {
infoTableName : "InfoTable",
dataShapeName : "datashapeName" //Since DataShape has the Value Fields in Order, new Table will be in Ordered Columns
};
var table2 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params_forOrder);
table2.AddField({ name: "timestamp", baseType: "DATETIME" });
//table1 has unordered table
var params_Merge = {
t1: table2, // Empty INFOTABLE
t2: table1 // Unordered INFOTABLE
};
// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Union(params_Merge);