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...
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Pargesoft
There's a line of the Record Link table which "Record ID" field is Purch. Rcpt. Header: 10-0010.
First test: 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.
Third test:
I tried to copy this record to a new one on the same table, changing 2 fields:
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...)
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.
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".
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): ?
(note that the batch should always be 'DEFAULT', but this is not granted...)
2) why is this linke necessary:
RecordLink.CALCFIELDS(Note);
?
Question : when I use this copy code, in case of a Record link Type = Note, the URL is completely wrong (the link is with the original link record, not the new one), do you know how to correct that?
For instance, I wanted to copy the Records Links after copy of the Customer records from a company to another (in new company, customers have new No. :
But oh my foes and oh my friends, it gives a lovely light
The fileds "URL 1" .. "URL 4" are text fields which are copied as is. They are concatenated to construct the full URL shown in the Links InfoBox. The URL is ment to point anywhere you like. So, an auto-update is out of question. The "Record ID" field is what points to the record the note is attached to.
Note that "Link ID" is an AutoIncrement field. You should set it to 0. Any other value re-initializes the Auto Increment value on the SQL Table. This costs performance and possibly causes problems when trying to insert a new record doing it as intended (i.e. from the default InfoBoxes).
You do not need to use a RecordRef to get a Record ID, a record has had a RECORDID property for many version now.
As a rule you should not use TRANSFERFIELDS to copy fields from one record to another of the same type. Just assign the record.
I am not sure about this, but I would guess that COPYLINKS copies Links and Notes. In fact @kine suggested this above and @ufuk confirmed it.