Strange Error [RESOLVED - NEW BUG]

David_CoxDavid_Cox Member Posts: 509
Hi Guys

I have a strange problem, with the code below, I have written this function to compare Rec to xRec field by field, it works great on most tables except tables with the field 'On Hold' which is a Code size 3 field.

When it reaches this field position 40 in the Purchase Header and 29 in the Gen. Journal Line, Both are the 'On Hold' Field, it crashes the system!

Run from the OnModify Trigger passing in xRec and Rec, works on most tables, so it's a strange one!

This is for Imported Orders and it works great on the purchase line, as I have a table for allowed edit fields, so the values cannot be changed but other infomation can.

NAV 4.30 and a GB SQL Database

Any Ideas??

OBJECT Codeunit 50000 TestCompare
{
  OBJECT-PROPERTIES
  {
    Date=08/06/07;
    Time=15:04:13;
    Modified=Yes;
    Version List=NAVW14.00.02,,ABSWW1.03;
  }
  PROPERTIES
  {
    Permissions=TableData 36=rm,
                TableData 37=rm,
                TableData 38=rm,
                TableData 39=rm;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    PROCEDURE CheckPurchHeader@1000000002(xRecPurchHeader@1000000000 : Record 38;PurchHeader@1000000001 : Record 38;FieldNo@1000000002 : Integer);
    VAR
      PurchHeader2@1000000007 : Record 38;
      recref_Original@1000000006 : RecordRef;
      recref_New@1000000005 : RecordRef;
      RecFieldNo@1000000004 : Integer;
      i@1000000003 : Integer;
    BEGIN
      WITH PurchHeader DO BEGIN
         recref_Original.GETTABLE(xRecPurchHeader);
         recref_New.GETTABLE(PurchHeader);
         FOR i := 1 TO recref_Original.FIELDCOUNT DO
              MESSAGE(STRSUBSTNO('Index %1 Table: %2 Field: %3 Old: %4 New: %5',
                   i,
                   recref_Original.NUMBER,
                   recref_Original.FIELDINDEX(i).NUMBER,
                   recref_Original.FIELDINDEX(i).VALUE,
                   recref_New.FIELDINDEX(i).VALUE
                   ));
      END;
    END;

    BEGIN
    END.
  }
}

:?
Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: [email protected]
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com

Comments

  • krikikriki Member, Moderator Posts: 9,086
    I can only think of 1 thing: Is the field enabled?
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • David_CoxDavid_Cox Member Posts: 509
    kriki wrote:
    I can only think of 1 thing: Is the field enabled?

    Yep!

    Standard unmodified tables!

    Just tested it on Native and it crashes that as well!

    Dave
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: [email protected]
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • krikikriki Member, Moderator Posts: 9,086
    I just tried something:
    I created a new table with an integer a text a code10 and a code3.
    And guess what : on the code3-field, Navision crashed.

    So I think you just found a beautiful bug with recordreferences.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • David_CoxDavid_Cox Member Posts: 509
    edited 2007-06-08
    kriki wrote:
    I just tried something:
    I created a new table with an integer a text a code10 and a code3.
    And guess what : on the code3-field, Navision crashed.

    So I think you just found a beautiful bug with recordreferences.

    :lol: I just changed the size of the On Hold field to 10 and it works fine :shock:

    So I will have to change the field length for now and limit the Chars to 3!

    Dave
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: [email protected]
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • krikikriki Member, Moderator Posts: 9,086
    I did some more testing:

    Try this:
    f1,f2 are fieldreferences.
    And to be honest, I never tried recref_Original.FIELDINDEX(i).VALUE.
    I always first create a fieldreference and get the value from there.
    WITH PurchHeader DO BEGIN
       recref_Original.GETTABLE(xRecPurchHeader);
       recref_New.GETTABLE(PurchHeader);
       FOR i := 1 TO recref_Original.FIELDCOUNT DO BEGIN
         f1 := recref_Original.FIELDINDEX(i);
         f2 := recref_New.FIELDINDEX(i);
         IF CONFIRM(STRSUBSTNO('Index %1 Table: %2 Field: %3 Old: %4 New: %5',
                 i,
                 recref_Original.NUMBER,
                 f1.NUMBER,
                 f2.VALUE,
                 f1.VALUE
                 ),FALSE) THEN;
       END;
    END;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • David_CoxDavid_Cox Member Posts: 509
    kriki wrote:
    I did some more testing:

    Try this:
    f1,f2 are fieldreferences.
    And to be honest, I never tried recref_Original.FIELDINDEX(i).VALUE.
    I always first create a fieldreference and get the value from there.
    WITH PurchHeader DO BEGIN
       recref_Original.GETTABLE(xRecPurchHeader);
       recref_New.GETTABLE(PurchHeader);
       FOR i := 1 TO recref_Original.FIELDCOUNT DO BEGIN
         f1 := recref_Original.FIELDINDEX(i);
         f2 := recref_New.FIELDINDEX(i);
         IF CONFIRM(STRSUBSTNO('Index %1 Table: %2 Field: %3 Old: %4 New: %5',
                 i,
                 recref_Original.NUMBER,
                 f1.NUMBER,
                 f2.VALUE,
                 f1.VALUE
                 ),FALSE) THEN;
       END;
    END;
    

    Works great and I will use the field ref to compare if changed!

    Thanks Again! :D
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: [email protected]
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.