I am currently working on a project where users can create sales. Within each sale, users are able to add multiple products which are stored in an array and then submitted to a table. I need each product row in the table to have a unique ID known as "line_num" for identification purposes when sending all products in the array via web service. My question is: How can I automatically generate this line_num for each product? For example, using the formula number of items in the array + 1.
Here is an example of the products array. I aim to automatically generate the "Line_num":2
for each entry.
[{"product_id":"11E822EF6E70F36EB430FA163EBBBC1D","Product_type_id":"11E7FC041F467AD4B09D00FF76874A58","Line_num":2,"Description":"dgdf","Quantity":3,"Unit_price":34,"Subtotal":102}]
Could someone provide suggestions on how to implement this in TypeScript code?
Appreciate your assistance.