A forum user needed help for a typical situation in dynamics nav. 2 users are working on the same sales order at the same time. both make changes. as a result one gets the error: the current record has an old load status, record was changed by an other user.
this is a so called race condition, means two persons want to change the same record or the value of the same field. at the time were the second person, who edited the record, wants to save his changes, the system realizes, that the status of the loaded record is old, because the first person has already saved his changes.
the question was: how to lock the sales order, when one user edits the record, so that a 2. user cannot edit the record.
how to solve the problem:
- the process answer: i most cases that should not be an issue, because only one user should work with one record at a time, e.g. one sales order. it makes no sense that 2 persons work at the same time with the same order. if that occurs, the work process in the company needs some optimization. So some consultancy is needed.
- situation 1: 2 persons do different things with the same order. In that case a workflow has to be defined, so that person 1 does his work first, then in step 2 person 2 his work step. result: never work 2 persons at the same time with the same order.
- situation 2: both do the same. then it’s needed to set the field assigned user, so that each person can filter the sales order list by that field and get so the assigned work load. as a result there is never a situation, where 2 persons work with the same order.
- tech answer: the issue is also solvable technically, but i recommend the process change.
- table sales header: add 2 fields InUse – boolean, UsedBy – code.20
- page 42 sales order, add following code to
IF UsedBy = USERID THEN BEGINUsedBy := ”;InUse := FALSE;modify;
IF NOT InUse THEN BEGINInUse := TRUE;UsedBy := USERID;modify;
END ELSEIF UsedBy <> USERID THENERROR(‘in use by %1’, UsedBy);