Skip to main content
Aug 19, 2021 7:14 AM UTC
Solved

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 */
});

}

Aug 24, 2021 5:07 AM UTC

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 */
});

3 replies

Aug 19, 2021 8:36 AM UTC

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.

Aug 19, 2021 10:11 AM UTC

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

AP_9587236AuthorAnswer
Aug 24, 2021 5:07 AM UTC

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 */
});