I need help with a rather trivial task – fully rollback a creation of new product (CachedUpdate = True
) when used two separate queries.
- Products list (list form/grid) – pretty short/light query, let’s say “number” and “name”.
- Particular product (
productcard
/edit form) – larger query, let’s say translation, nutrition fact and possibly detail tables – prices, bar codes etc.
Even without detail tables I want to separate those to queries – in list I do not need to much fields. In first version my workflow was as follows:
- Product list.
If I need to edit – nothing special. I was able to update exact row (by calling
RefreshRecord
) in list if successfully was updated product in edit form. - If I need to add new product – pain in the ass. My decision was to do in the same way (as described in in the previous sentence). So, I did it with that code:
Problem here isvar oRow := mtTable.Table.NewRow; //RowState here = rsDetached oRow.ValueO[mtTable.Table.Columns.ColumnByName('Id')] := MyKey; mtTable.Table.Rows.Add(oRow); //rowState here = rsEdited
RefreshRecord
. It does nothing ifRowState
isrsDetached
/rsInserted
.
Some detail found here: /
Maybe there is a problem from the beginning. How to make first query reflecting data from second one, if new product was added? How to assign id from detail table (if was added new row) to new one? Can I do what I want but in more elegant way?