Skip to main content
1-Visitor
February 11, 2020
Solved

adding multiple entries in a datatable with the same primary key

  • February 11, 2020
  • 14 replies
  • 5135 views

I have a datatable with productname as primary key. i have two list widgets, one for product name and one for quantity. Now, for examples, if i select a product,say, a PCB and quantity as 2, then my datatable should make 2 entries having product name as PCB only. how do i do that? 

Best answer by raluca_edu

You should call Add service in the new service you are creating.

You can check also AddorUpdateDataTablesEntries (this is allowing you to add more than one entry in datatable).

 

Regards,

Raluca Edu

14 replies

18-Opal
February 11, 2020

Hello @gourinaik98,

 

If you use product name as primary key, you won't be able to insert two rows into your data table with the same product name. You should either insert one row with quantity = 2, or insert two rows, but use a combination of product name + quantity as your primary key.

 

/ Constantine

1-Visitor
February 11, 2020
Can u elaborate on the latter option of using 2 primary keys?
18-Opal
February 11, 2020

It's a composite primary key rather than two different keys. Just check "Primary key" for two fields in your datashape.