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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

updating entries in datatable

AP_9587236
17-Peridot

updating entries in datatable

Why both of these codes are not updating the entries in datatable. it is not showing error as well. Someone please tell me how to approach this code.

1. var params5 = {
infoTableName : "InfoTable",
dataShapeName : "MACMON_ProductionPlanDT_DS"
};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(MACMON_ProductionPlanDT_DS)
var updateDT = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params5);

updateDT.ToolHistoryID=rowDT.ToolHistoryID;
updateDT.MachineName=MachineName;
updateDT.PlannedTimeStart=rowDT.PlannedTimeStart;
updateDT.PlannedTimeEnd=rowDT.PlannedTimeEnd;
updateDT.QualityScore=resultDT.rows[i].QualityScore;
updateDT.QualityScoreUpdatedBy=QualityUpdatedBy;

Things[productionPlannerDT].UpdateDataTableEntries({
sourceType: undefined /* STRING */,
values: updateDT /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});

-------

2. var params5 = {
infoTableName : "InfoTable",
dataShapeName : "MACMON_ProductionPlanDT_DS"
};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(MACMON_ProductionPlanDT_DS)
var updateDT1 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params5);
var updateDT = new Object();
updateDT.ToolHistoryID=rowDT.ToolHistoryID;
updateDT.MachineName=MachineName;
updateDT.PlannedTimeStart=rowDT.PlannedTimeStart;
updateDT.PlannedTimeEnd = rowDT.PlannedTimeEnd;
updateDT.QualityScore=resultDT.rows[i].QualityScore;
updateDT.QualityScoreUpdatedBy=QualityUpdatedBy;
updateDT1.AddRow(updateDT);

Things[productionPlannerDT].UpdateDataTableEntries({
sourceType: undefined /* STRING */,
values: updateDT1 /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});

}

ACCEPTED SOLUTION

Accepted Solutions

This worked actually. 

 

var ID=rowDT.ToolHistoryID;
var MName=MachineName;
var TimeStart=rowDT.PlannedTimeStart;
var TimeEnd=rowDT.PlannedTimeEnd;
var QScore=resultDT.rows[i].QualityScore;
var QSUpdatedBy=QualityUpdatedBy;

updateDT.ToolHistoryID=ID;
updateDT.MachineName=MName;
updateDT.PlannedTimeStart=TimeStart;
updateDT.PlannedTimeEnd=TimeEnd;
updateDT.QualityScore=QScore;
updateDT.QualityScoreUpdatedBy=QSUpdatedBy;


Things[productionPlannerDT].UpdateDataTableEntries({
sourceType: undefined /* STRING */,
values: updateDT /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});

View solution in original post

3 REPLIES 3

You should try step by step:

updateDT.ToolHistoryID=rowDT.ToolHistoryID;
updateDT.MachineName=MachineName;
updateDT.PlannedTimeStart=rowDT.PlannedTimeStart;
updateDT.PlannedTimeEnd=rowDT.PlannedTimeEnd;
updateDT.QualityScore=resultDT.rows[i].QualityScore;
updateDT.QualityScoreUpdatedBy=QualityUpdatedBy;

 

These properties are assigned with value from infotable input, is that correct?   So try with direct string and numeric service input first, and make the service execute succesfully.

 

And for updateDT1.AddRow(updateDT);,  you may check wether it's useful.

AP_9587236
17-Peridot
(To:zyuan1)

Some of the fields Base Type is "DATETIME". I am getting error while trying to hardcode any value for this in js code. 

This worked actually. 

 

var ID=rowDT.ToolHistoryID;
var MName=MachineName;
var TimeStart=rowDT.PlannedTimeStart;
var TimeEnd=rowDT.PlannedTimeEnd;
var QScore=resultDT.rows[i].QualityScore;
var QSUpdatedBy=QualityUpdatedBy;

updateDT.ToolHistoryID=ID;
updateDT.MachineName=MName;
updateDT.PlannedTimeStart=TimeStart;
updateDT.PlannedTimeEnd=TimeEnd;
updateDT.QualityScore=QScore;
updateDT.QualityScoreUpdatedBy=QSUpdatedBy;


Things[productionPlannerDT].UpdateDataTableEntries({
sourceType: undefined /* STRING */,
values: updateDT /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
tags: undefined /* TAGS */
});

Announcements


Top Tags