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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

auto-generate primary key in datatable

xiaoqw
15-Moonstone

auto-generate primary key in datatable

clipboard_image_0.png

var week = me.GetWeekNumber({ date: when }); // Copied from Stack Overflow, didn't test its correctness
var month = when.getMonth(); // Zero-based
var year = when.getFullYear();
var correctmonth = month +1;

me.AddDataTableEntries({ values: me.CreateValuesWithData({ values: {
id: generateGUID(),
value: value,
Kategory: Kategory,
Department:Department,
Line: Line,
SKU : SKU,
KPI_Details: KPI_Details,
Target: Target,
Other_Target : Other_Target,
Other_value : Other_Value,
week: week,
month: correctmonth,
year: year
} }) });

As below attached, when refreshing the page, grid will auto-generate a new line. The primary key type is GUID. How to stop auto-generate new rows when I refresh the page and when user update data, new data will show in the grid without key in primary key manually.

0 REPLIES 0
Top Tags