i would like to select one particular line in a grid control. I have following code at end of the write method of smmBusRelTable data source.
...
//copy current line to buffer
_smmBusRelTable = smmBusRelTable;
//and execute query
//after this i am on another line in a grid control
this.executeQuery();
//i try to jump to the old line
this.markRecord(_smmBusRelTable);
My friend has already helped me to solve the problem.
Below is correct code
....
//copy primary key of current line to buffer
smmAccount = smmBusRelTable.BusRelAccount;
//and execute query
//after this i am on another line in a grid control
this.executeQuery();
//and now jump to the old line
this.findRecord(SmmBusRelTable::find(smmAccount));
this.refresh();
When you assinged the value of one table variable to the other, you did not copy the data to the new table variable, but simply pointer it to the same cursor as the first one.
And, of course, after the cursor was changed, both table variables pointed to the new cursor, and not the one you were trying to save.
To avoid this, you could save the key field instead, (that's what you did) or, you could use the special method data() to copy the value of the cursor, like the following:
Comments
Below is correct code
When you assinged the value of one table variable to the other, you did not copy the data to the new table variable, but simply pointer it to the same cursor as the first one.
And, of course, after the cursor was changed, both table variables pointed to the new cursor, and not the one you were trying to save.
To avoid this, you could save the key field instead, (that's what you did) or, you could use the special method data() to copy the value of the cursor, like the following:
_smmBusRelTable.data(smmBusRelTable);
My blog - http://kashperuk.blogspot.com
MorphX IT in Russian - http://www.lulu.com/content/723888
Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582