Skip to main content
17-Peridot
August 19, 2021
Solved

updating entries in datatable

  • August 19, 2021
  • 2 replies
  • 1378 views

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

}

Best answer by AP_9587236

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

2 replies

5-Regular Member
August 19, 2021

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.

17-Peridot
August 19, 2021

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

AP_958723617-PeridotAuthorAnswer
17-Peridot
August 24, 2021

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