Create note - Record Link formatting problem when saving

Pablogrind
Member Posts: 13
With the same code and only changing the text it produces different results
RESULT:

the text is truncated
RESULT:

the text is invalid
changed to TextEncoding::Windows I have the same result, what could it be?
procedure FillNote() var Customer: Record Customer; RecordLink: Record "Record Link"; outStr: OutStream; MyInStream: InStream; begin Customer.GET('00000006'); Clear(RecordLink); RecordLink.Init(); RecordLink."Record ID" := Customer.RecordId(); RecordLink.Type := RecordLink.Type::Note; RecordLink."Link ID" := 0; RecordLink.Created := CurrentDateTime; RecordLink."User ID" := USERID; RecordLink.Company := CompanyName; RecordLink.Note.CreateOutStream(outStr, TextEncoding::UTF8); outStr.WRITETEXT('1111111111111 2222222222222 33333333333333 444444444444 555555'); if RecordLink.Insert(true) then Message('Si') else Message('No'); end;
RESULT:

the text is truncated
procedure FillNote() var Customer: Record Customer; RecordLink: Record "Record Link"; outStr: OutStream; MyInStream: InStream; begin Customer.GET('00000006'); Clear(RecordLink); RecordLink.Init(); RecordLink."Record ID" := Customer.RecordId(); RecordLink.Type := RecordLink.Type::Note; RecordLink."Link ID" := 0; RecordLink.Created := CurrentDateTime; RecordLink."User ID" := USERID; RecordLink.Company := CompanyName; RecordLink.Note.CreateOutStream(outStr, TextEncoding::UTF8); outStr.WRITETEXT('AAA BBB CCC DDD EEE FFF'); if RecordLink.Insert(true) then Message('Si') else Message('No'); end;
RESULT:

the text is invalid
changed to TextEncoding::Windows I have the same result, what could it be?
0
Answers
-
try like below (I got it from mibuso):
function AddMemo(loc_rec : Record "Payment Lines";ApproveComment : Text[250])
SystemUTF8Encoder := SystemUTF8Encoder.UTF8Encoding;
SystemByteArray := SystemUTF8Encoder.GetBytes(ApproveComment);
RecLink.INIT;
RecLink.Type := RecLink.Type::Note;
RecLink.Created := CURRENTDATETIME;
RecLink."Record ID" := loc_rec.RECORDID;
RecLink.Description := ApproveComment;
IF MailAdressText <>'' THEN
RecLink."User ID":= GetUserByEmail(MailAdressText);
IF RecLink."User ID" = '' THEN
RecLink."User ID" := USERID;
RecLink.Company := COMPANYNAME;
RecLink.CALCFIELDS(Note);
CLEAR(RecLink.Note);
RecLink.Note.CREATEOUTSTREAM(OutStr);
x := SystemByteArray.Length DIV 128;
IF x > 1 THEN
y := SystemByteArray.Length - 128 * (x - 1)
ELSE
y := SystemByteArray.Length;
c1 := y;
OutStr.WRITE(c1);
IF x > 0 THEN BEGIN
c2 := x;
OutStr.WRITE(c2);
END;
FOR i := 0 TO SystemByteArray.Length - 1 DO BEGIN
c1 := SystemByteArray.GetValue(i);
OutStr.WRITE(c1);
END;
RecLink.INSERT;
RecLink Record Record Link
OutStr OutStream
Encoding TextEncoding
x Integer
y Integer
i Integer
c1 Char
c2 Char1 -
Hello,
Instead ofRecordLink.Note.CreateOutStream(outStr, TextEncoding::UTF8); outStr.WRITETEXT('AAA BBB CCC DDD EEE FFF');
you should useTypeHelper.WriteRecordLinkNote(RecordLink,'AAA BBB CCC DDD EEE FFF');
TypeHelper is Codeunit 10 "Type Helper".
You can see an example of use in Codeunit 454.2 -
Awesome, thankss0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions