Insufficient Memory when using events

The following code crashes the client:

Object.SETRANGE(Type, Object.Type::Table);
  OnBeforeDataItem(RecRef, Allowed); // This is an integration event
  OnAfterDataItem(RecRef); // This is another integration event
UNTIL Object.NEXT = 0;

These events have no subscribers

Thank you Microsoft !!!!

  • OK, Update:

    It is not possible to call more than 998 Events in a row - even though there is no subscriber.

    This also means that it might not be possible to post a journal with more than 998 lines in it.

    The following code also fails:

    FOR I := 1 TO 1000 DO


    Anyway - it seems that I found a workaround.

    Instead of creating the events as local functions in the CU where it should be (like posting CU), we create them in a seperate codeunit as local events, then we create a function in that CU which calls the Event:

    LOCAL [IntegrationEvent] OnBeforeSomething(VAR RecRef : RecordRef;VAR Allowed : Boolean)

    RaiseOnBeforeSomething(VAR RecRef : RecordRef;VAR Allowed : Boolean)

    Then call the RaiseFunction in the EventRaiser CU and it works for a million records (as far as I have seen),

    Even though this is a valid workaround, it is a nightmare and a pain to have to consume another object just becase of raising events.


    Conclusion: Never raise an event in the same object where you declare it !!!

Reply Children
No Data