How to copy Notes (stored in Record Links table)

AtreiuAtreiu Member Posts: 51
edited 2010-04-19 in NAV Three Tier
Hi everybody,
I'm getting crazy with this...

Example:
In the RTC client I add a note to the Sales Order #100. The program write it in the Record Links table and the only way to know that my Sales Order 100 has a note is to read the field "RecordID" in the Record Links table.
The Sales Header has no link field like that...

When I post my order, I want to copy the note in the Shipment (and then in the Invoice). I cannot do this.

I've tried to filter Record Links table, but it's not possible to use "Record ID" to filter (I cannot compare a RECORDID data type to a text type, and it's not possible to convert the text into RECORDID). I also cannot write another text field where to copy the value from Record ID...

any suggestion?

thanks...

Comments

  • kinekine Member Posts: 12,562
    I am not sure, but cannot you use the "HASLINKS", "COPYLINKS" etc. command to work with the notes like with any other links?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • ufukufuk Member Posts: 512
    You can use copylinks as Kine said and you can also apply filters like:
    RecLink.SETFILTER("Record ID",FORMAT(prec."Record ID"));
    
    or
    RecLink.SETFILTER("Record ID",SalesHeader.TABLENAME+': '+FORMAT(SalesHeader."Document Type")+','+SalesHeader."No.");
    
    Ufuk Asci
    Pargesoft
  • AtreiuAtreiu Member Posts: 51
    Ok, being a newbie, I'm going with baby steps...

    There's a line of the Record Link table which "Record ID" field is Purch. Rcpt. Header: 10-0010.

    First test:
    RecordLink.SETFILTER("Record ID",'Purch. Rcpt. Header: 10-0010');
    IF RecordLink.FINDSET(TRUE) THEN
    MESSAGE('Record ID %1',RecordLink."Link ID");
    
    and it returns the right value.

    Second test:
    I put this code in the codeunit 333 and tried to copy the links to the purchase order, but it did not work.
    PurchOrderHeader.COPYLINKS(RecordLink);
    

    Third test:
    I tried to copy this record to a new one on the same table, changing 2 fields:
    RecordLink.INIT;
    RecordLink.TRANSFERFIELDS(RecordLink);
    RecordLink."Link ID" := 71;
    RecordLink."Record ID" :='Purchase Header: Ordine,10-0562';
    RecordLink.INSERT;
    

    I get the usual error "invalid type" RecordID := Text.



    (in the classic client there are no notes, so I can't use the debugger... does anybody have any idea about how navision create records in the Record Links table? I've found no Codeunit doing that, for example...)
  • AlishaAlisha Member Posts: 217
    I did this code that copies Notes from one Customer to another, using RecordRef, maybe you can use it to copy the note to another table:


    CALCFIELDS(Note);
    NewRecLink.INIT;
    NewRecLink.TRANSFERFIELDS("Record Link");
    NewRecLink."Link ID" := entryNo;
    entryNo +=1;

    NewRecRef.OPEN(18);
    NewRecRef.GETTABLE(NewCust);
    NewRecLink."Record ID" := NewRecRef.RECORDID;

    NewRecLink.INSERT;
    NewRecRef.CLOSE;

    NewCust is a record variable that contains the new customer, "Record Link" contains the current Note for the current customer.
  • AtreiuAtreiu Member Posts: 51
    Hi everybody
    I got it!
    Thanks to all!!! You're great. =D>


    This is the explanation of what I've done (for other ignorant people like me...).
    And maybe the experts can "validate it" :) or tell me if it could be even better (or something useless I've written)... (and let me know how to mark this topic as 'solved')

    General information:
    - copy from a Requisition request to a Purchase order.
    - CodeUnit 333 - Req. Wksh.-Make Order

    Global variables:
    [Name DataType Subtype Length]
    RecordLink Record Record Link
    NewRecLink Record Record Link
    NewRecRef RecordRef
    NewOrder Record Purchase Header
    MaxLinkID Integer
    LinkID Integer

    I created the function CopyRecordLinks with the local parameter:
    Var Name DataType Subtype Length
    Sì ReqLine Record Requisition Line

    and it is called in the CarryOutReqLineAction function, when the action message is "new".
    //Calcolo il massimo Link ID utilizzato nella tabella Record Links
    REPEAT
    LinkID := RecordLink."Link ID";
    IF LinkID > MaxLinkID THEN
    MaxLinkID := LinkID
    UNTIL  RecordLink.NEXT = 0;
    
    //Filtro tutti i link relativi alla mia richiesta d'approv.
    RecordLink.SETFILTER("Record ID",'Requisition Line: RICH.,DEFAULT,'+FORMAT(ReqLine."Line No."));
    
    //Se trovo dei link vado a copiarli nell'ordine d'acquisto
    IF RecordLink.FINDSET(TRUE) THEN BEGIN
          REPEAT
             RecordLink.CALCFIELDS(Note);
             //Copio il record 
             NewRecLink.INIT;
             NewRecLink.TRANSFERFIELDS(RecordLink);
             NewRecLink."Link ID" := MaxLinkID+1;
    
             //Creo una variabile 'record' con il numero dell'ordine di acquisto creato
             NewOrder.INIT;
             NewOrder.GET(NewOrder."Document Type"::Order,PurchOrderHeader."No.");
    
             //Faccio riferimento alla variabile dell'ordine e creo un nuovo link con quel riferimento
             NewRecRef.OPEN(38);
             NewRecRef.GETTABLE(NewOrder);
             NewRecLink."Record ID" := NewRecRef.RECORDID;
             NewRecLink.INSERT;
             NewRecRef.CLOSE;
             //Aumento il contatore per il prossimo eventuale record
             MaxLinkID += 1;
          UNTIL  RecordLink.NEXT = 0;
    END;
    COMMIT;
    

    Some questions:
    1) could I improve this part
    RecordLink.SETFILTER("Record ID",'RequisitionLineRequisition Line: RICH.,DEFAULT,'+FORMAT(ReqLine."Line No."));
    writing something similar to this (copied from another discussion):
    IF PurchaseHeader.HASLINKS THEN
    BEGIN
      RecRef.OPEN(DATABASE::"Purchase Header");
      RecRef.GETTABLE(PurchaseHeader);
      PurchHeaderRecordID := RecRef.RECORDID;
      RecordLink.SETRANGE(RecordLink."Record ID",PurchHeaderRecordID);
      IF RecordLink.FINDSET THEN
      REPEAT
        MESSAGE(RecordLink.URL1);
      UNTIL RecordLink.NEXT = 0;
    END;
    
    ?
    (note that the batch should always be 'DEFAULT', but this is not granted...)

    2) why is this linke necessary:
    RecordLink.CALCFIELDS(Note);
    ?
  • DoomhammerDoomhammer Member Posts: 209
    Hi folks, thank you for nice recordref walkthrough :smile:
    Martin Bokůvka, AxiomProvis
Sign In or Register to comment.