How BO knows if the current record is the last update ?
to explain my question, do the following action
Open 2 times the form Business Partner, and choose on both form the same BP. Make a small change on the first form and save it.
Now, make an other change on form 2 and try to save. You have a message "Another user-modified table 'Business Partner'"
It means there is a mechanism that check if the record is the last version.
I can't find out how this mechanism works. I thought that was something with the history table, but you can set the number of record to 0. I looked at the fields in the table, but no one can tell this information.
I have created my own form for OINS (Customer Equipment Card), and I need to have the same mechanism. I use a DI object to upate the table.
Do you have an idea how it's done in BO ?
John Mackin replied
Interesting question - just had a look to see how its done and here is what I found based on the BP screen in V2005 SP0 Patch5:-
Basically B1 remembers the original value of any of the fields that you have changed on the screen. Before it does the update, it performs a SQL Select statement on the underlying table (in this case OCRD) using a where clause consisting of the original values of any fields that you have changed. If it finds a match then that means that no-one else has modified those fields and the update can go through. However if the query returns 0 records then that means someone else must have changed at least one of the fields so B1 will not do the update and instead give you the 'Another User....' message.
For example if I find a BP record (Cardcode = "X Y") and it is showing
and I try to update these 3 fields, the check that B1 will do is
SELECT COUNT('A') FROM [dbo].[OCRD] T0 WHERE T0.CardCode = N'X''Y ' AND T0.Phone1 = N'3' AND T0.Phone2 = N'2' AND T0.Cellular = N'3'
This mechanism is actually pretty good as it means that 2 users can do concurrent updates as long as they are to different fields. For example if you open 2 bp screens, find the same record, but one users updates "Phone1" and the other users updates "Phone2", both the updates can succeed.
Hope this helps you build your custom screen.