Using Write Now — also called "Save immediate" — can case data integrity issues that cause such errors. You need to find a way to avoid using the Save immediate processing.
For example, when you first create a work object , you don't have a lock on it , so if you write it to the database using Save-immediate, somebody else can acquire the object and start modifying it.
Clear the WriteNow checkbox in any activity of type Trigger,Utility,Notify,Assign or Route and in situations where you want to mark a page to be saved, but want the system to perform the database commit later.
The System determines whether a lock is already present on the instance. If the current session does not hold a lock (and the instance belongs to a lockable class) the method fails.
If the WriteNow checkbox is selected, the system then deletes any old instance with that key and adds a new one. No locks are released. If the WriteNow checkbox is cleared, the system adds this page to the set of deferred-write pages for this requestor.