Count Links

117320117320 Member Posts: 33
edited 2014-03-05 in NAV Three Tier
Hi All,

How can I count how many Links on a document from C/AL code?

If I open the form(my attachment) manually, I can see there are 2 links.

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Count the number of records in table 2000000068 "Record Link" for the given record.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • 117320117320 Member Posts: 33
    Hi Luc,

    I want to count by per document.

    If possible, please advise me the code.

    Thank you
  • lubostlubost Member Posts: 625
    Hi,

    Table "Record Link" is based on RecordID and the main part of RecordID is the table part. RecordID field can not be filtered directly and you have to use some trick:

    RecRef := YourRecord.GETTABLE;
    RecordLink.SETFILTER(RecordID, '%1', FORMAT(RecRef.ID));

    and now you are able count resulting recordset.
  • 117320117320 Member Posts: 33
    Hi Lubost,

    thank you for the code, appreciate it. It work with some modification :

    RecRef := YourRecord.GETTABLE;
    RecordLink.SETRANGE(RecordID, RecRef.RECORDID);
  • tinoruijstinoruijs Member Posts: 1,226
    Just 'discovered' Notes are record links of type Note.
    So I just added this to count the notes.
    RecordLink.SETRANGE(Type, RecordLink.Type::Note);
    

    Tino Ruijs
    Microsoft Dynamics NAV specialist
Sign In or Register to comment.