
I am facing an issue related to saving dynamic column values in a Sales Order scenario.
I have two related screens:
First screen
This screen is used to store locations related to a Sales Order.
The number of locations is dynamic and not fixed per Sales Order.
Locations are saved correctly in this screen.
Second screen
In this screen:
The previously stored locations are dynamically converted into columns.
The rows represent the Sales Order items (lines).
Each cell should store the quantity/value of a specific item in a specific location.
When saving data from the second screen:
The values entered for all rows are incorrectly saved as the same values of the last row only.
As a result, in the SQL table, all item lines end up having identical values, matching the last inserted/updated row.
This behavior occurs despite the UI showing different values per row before saving.
I have attached:
The screen code used for handling the dynamic columns and saving the data.
Screenshots showing:
The dynamic locations setup
The dynamic grid layout
The incorrect data stored in the SQL table
What is the correct approach in Dynamics 365 to handle saving data from a grid with dynamic columns, ensuring that each row is saved with its own correct values and not overwritten by the last row?
Any guidance, best practices, or examples would be highly appreciated.