Client crash by RecordRef ?

einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
Greetings Earthlings! :wink:

I have a very strange system behaviour after implementing a new function. Maybe someone knows about problems with RecordRef.

I created a new functionality very similar to the Change Log functionality. The only difference is that my function isn't called by CU 1 but by the Modify Trigger of some tables or by the Validate Trigger of certain fields of these tables. And of course I don't use the Change Log Tables to setup my function and to store the created entries.

If my function is called by the Modify Trigger then the client crashes always after the function IsNormalField has been called. The Debugger steps back into the function LogModification and the windows message for reporting the error pops up. Nothing else. No "internal error x in module y" or something like that.

If my function is called by the Validate Trigger of a field then it works really good.

Does anyone has a suggestion what I can do?
"Money is likewise the greatest chance and the greatest scourge of mankind."

Comments

  • SavatageSavatage Member Posts: 7,142
    Knowing the X & Y would probably be helpful
    "internal error x in module y"
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Sorry, but there is no X and no Y because there is no such an error message!
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • SavatageSavatage Member Posts: 7,142
    Oh oops - I see my reading mistake now :oops:

    So basically your having problems using your code in OnModify but it works fine in OnValidate.
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Yes, that's the only difference I can see.

    But I don't think it has anything to do with this difference. I think it's the way Navision handles RecordRefs. Maybe I should post the code of both functions. Normally everybody who worked for a longer time with the Navision development environment should have heard of these functions but maybe only a few keep them in mind.

    IsNormalField(TableNumber : Integer;FieldNumber : Integer) : Boolean
    GetField(TableNumber,FieldNumber,Field);
    EXIT(Field.Class = TempField.Class::Normal);
    

    LogModification(VAR RecRef : RecordRef;VAR xRecRef : RecordRef)
    IF NOT IsLogActive(RecRef.NUMBER,0,1) THEN
      EXIT;
    FOR i := 1 TO RecRef.FIELDCOUNT DO BEGIN
      FldRef := RecRef.FIELDINDEX(i);
      xFldRef := xRecRef.FIELDINDEX(i);
      IF IsNormalField(RecRef.NUMBER,FldRef.NUMBER) THEN
        IF FORMAT(FldRef.VALUE) <> FORMAT(xFldRef.VALUE) THEN
          IF IsLogActive(RecRef.NUMBER,FldRef.NUMBER,1) THEN
            InsertLogEntry(FldRef,xFldRef,RecRef,1);
    END;
    

    The debugger goes through the function IsNormalField and jumps back into the function LogModification and then the client crashes. I put in a message in like this
    IF IsNormalField(RecRef.NUMBER,FldRef.NUMBER) THEN BEGIN
        MESSAGE('Back in LogModification');
        IF FORMAT(FldRef.VALUE) <> FORMAT(xFldRef.VALUE) THEN
    
    but even this message will not be executed.

    I even made a client update (technical). Now 4.00 SP3 but it didn't solve the problem.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • Timo_LässerTimo_Lässer Member Posts: 481
    I recognized in the past, that NAV will crash without any error message if you access a text or code field with a field length (by design) less than 5 (or 10?) characters.
    Solution: Extend the field length to a minimum of 10 characters.
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Good idea. But sorry, there is no field with such a small field length within my table.

    I have read here in one topic that there are some problems with RecordRef if you have not closed the RecordRef correct. And in another topic that there will be a check for an incorrect close of RecordRef in NAV 5.0. Sorry, but I can't find both topics again yet. Maybe it has something to do with that problem?

    [edit]
    this is the first topic ... (still searching for)
    and this is the 2nd topic http://www.mibuso.com/forum/viewtopic.php?t=19865

    I tried to put in a RecRef.CLOSE after every call, but that didn't solve the problem anyway. Maybe I should use CLEAR instaed of CLOSE or maybe RESET as suggested in this thread http://www.mibuso.com/forum/viewtopic.php?t=17087???
    [/edit]
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I tried CLEAR, CLOSE and RESET, but it did not solve the problem.

    I think the problem is comparable to this problem http://www.mibuso.com/forum/viewtopic.php?t=14150. A function that works really great is called in another context and the Navision Client will crash. Very strange!
    "Money is likewise the greatest chance and the greatest scourge of mankind."
Sign In or Register to comment.