Issue while deleting records via businessentity
 
Forums / SmartComponent Library - Developer Forum / Issue while deleting records via businessentity

Issue while deleting records via businessentity

4 posts, 1 answered
  1. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    Answered
    21 May 2021
    Link to this post
    So i have a business-entity which reads some additional fields in ReceiveData().

    If i call the Entity via HTTP Delete i get the following message:

    The current row has been changed by another user! (11913)elwstatistik"

    In ReceiveData() i put
    IF NOT THIS-OBJECT:RequestType = RequestTypeEnum:FetchData THEN
                RETURN.

    But I logged that ReceiveData() is actually called twice if im deleting a record. And at the first time the THIS-OBJECT:RequestType is still Fetch so it changes the elwstatistik record.

    I don't encounter the problem if i test the code via ablunit. Im quiet confused. I will put the code down below.

    Entity :
    https://pastebin.com/8pSf7BNf

    TestCase
    https://pastebin.com/A9U8stQh
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    22 May 2021 in reply to Markus Grigoleit
    Link to this post
    It is expected that the DELETE request reads the record first. That's a FetchData request. We need to obtain the current values of the record so that it's available in validation etc.. The whole CUD (create, update, delete) operations rely on a before-buffer. And as RESTful does not provide the before buffer with the request, we need to built that from the current DB record while processing the request. 

    With the error 11913 - that's typically happening, when in ReceiveData (or another method) you are modifying a data-bound temp-table field. That will make the deleted record's before-buffer values appear different from the values's in the DB, thus the ProDataset will consider them as changed by another user. 

    You could try to change the value of the temp-table buffer's MERGE-BY-FIELD property (https://docs.progress.com/ru-RU/bundle/openedge-developer-studio-help/page/MERGE-BY-FIELD-attribute.html). This could be set in an SaveChanges override in your Data Access class.
  3. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    22 May 2021 in reply to Mike Fechner
    Link to this post
    Just seen MERGE-BY-FIELD is an attribute of the DATA-SOURCE; not the BUFFER. Minor detail though. 
  4. Markus Grigoleit
    Markus Grigoleit avatar
    31 posts
    Registered:
    04 Jun 2019
    25 May 2021
    Link to this post
    Hello Mike,
    With the error 11913 - that's typically happening, when in ReceiveData (or another method) you are modifying a data-bound temp-table field.

    This part really got me thinking. It was bugging me why i didnt encounter the problem earlier, since i used to read additional data in BE all the time. But then i noticed that the field which is set via the  ReceiveData() is indeed a field not added to the e-TT but rather a data-bound field of the table itself.

    As a workaround i just created a new businesstask for deleting records.
    Thanks tho!
4 posts, 1 answered