Options

RecordRef.GETTABLE vs. RecordRef.SETTABLE

Slawek_GuzekSlawek_Guzek Member Posts: 1,690
edited 2010-02-03 in NAV Tips & Tricks
Who knows the difference ?

Regards,
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03

Comments

  • Options
    kinekine Member Posts: 12,562
    Regarding the on-line help, the SETTABLE will apply filters from the record to the recordref too. GETTABLE will set only the table.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Yes Kine. I've checked in on-line help as well. And did some tests before asking question here.

    According to my tests both SETTABLE and GETTABLE copy filters from record to recordref.

    Just wonder if anyone knows real difference between those two functions...

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    krikikriki Member, Moderator Posts: 9,096
    Actually, the help is wrong (I didn't check the help of NAV2009 though).

    In reality GETTABLE is for putting a record-variable into a recordreference and SETTABLE does the opposite.

    If you put a record into a recordreference, it also copies the filters.
    If you put a recordreference into a record, it doesn't! (I didn't check NAV2009 though).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    kinekine Member Posts: 12,562
    Yes Kine. I've checked in on-line help as well. And did some tests before asking question here.

    According to my tests both SETTABLE and GETTABLE copy filters from record to recordref.

    Just wonder if anyone knows real difference between those two functions...

    Regards,
    Slawek

    Ok, didn't know that. But just looking on the function names I assumed what Kriki described, but I know that the SETTABLE is not working as I will assume. Thus I looked into on-line help.

    To set filters to record I am using the Rec.SETVIEW(RecordRef.GETVIEW).
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    BeliasBelias Member Posts: 2,998
    NAV2009:
    help has been fixed, functionality hasn't been(i tested it with this code, from a kriki tip&trick)
    I tested it with both setrange and setfilter (who knows if this could change something? :mrgreen: ) without success.
    what a shame...
    TBSalesInvHead.SETFILTER("Your Reference",'12');
    rer[1].GETTABLE(TBSalesInvHead);
    rer[2].GETTABLE(TBSalesCrMemoHead);
    
    recField[1].RESET;
    recField[1].SETCURRENTKEY(TableNo,"No.");
    recField[1].SETRANGE(TableNo,DATABASE::"Sales Invoice Header");
    IF recField[1].FINDSET THEN
      REPEAT
        IF recField[2].GET(DATABASE::"Sales Cr.Memo Header",recField[1]."No.") THEN
          IF (recField[1].FieldName = recField[2].FieldName) AND
             (recField[1].Type = recField[2].Type) AND
             (recField[1].Len = recField[2].Len) AND
             (recField[1].Class = recField[2].Class) AND
             (recField[1].Enabled = recField[2].Enabled) THEN BEGIN
            fir[1] := rer[1].FIELD(recField[1]."No.");
            fir[2] := rer[2].FIELD(recField[2]."No.");
            fir[2].SETFILTER(fir[1].GETFILTER);
          END;
      UNTIL recField[1].NEXT = 0;
    
    rer[2].SETTABLE(TBSalesCrMemoHead);
    
    MESSAGE(TBSalesCrMemoHead.GETFILTERS);
    MESSAGE(TBSalesInvHead.GETFILTERS);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    gerdhuebnergerdhuebner Member Posts: 155
    Belias wrote:
    NAV2009:
    help has been fixed...
    This is from C/SIDE Reference Guide (Online Help):
    SETTABLE Function (RECORDREF):
    Any filters that are applied to the recordref are also applied to the record. If you change the filter that is applied to the recordref, you must call SETTABLE again to apply the new filter to the record.

    In fact, no filter is transferred at all from a recordref to a record.
    So it seems that neither online help nor the bug has been fixed (though it would have been sufficient to fix one of them, not both :mrgreen:). This is true for NAV 2009 SP1, too.
  • Options
    mbjmbj Member Posts: 63
    If you put a recordreference into a record, it doesn't - then you have to use SET AND GETVIEW.

    JobRec.SETVIEW(MyRecordRef.GETVIEW);

    Then you also have the filters.
Sign In or Register to comment.