Hi guys,
I've been stuck on that for a little while and I hope someone can help me.
I'm using NAV 2009 R2.
I need to read/write notes in a codeunit. This codeunit is then going to be used by a web service.
This is my function to write a note
NotificationText.ADDTEXT(NotificationText2);
RecordLink.INIT;
RecordLink.”Record ID” := RecRef.RECORDID;
RecordLink.URL1 := CreateURL(RecRef,ObjectID);
RecordLink.Description := Caption;
RecordLink.Type := RecordLink.Type::Note;
RecordLink.Created := CURRENTDATETIME;
RecordLink.”User ID” := USERID;
RecordLink.Company := COMPANYNAME;
RecordLink.Notify := TRUE;
RecordLink.”To User ID” := USERID;
RecordLink.INSERT(TRUE);
RecordLink.Note.CREATEOUTSTREAM(OutStream);
Encoding := Encoding.GetEncoding(437);
BinaryWriter := BinaryWriter.BinaryWriter(OutStream,Encoding);
BinaryWriter.Write(FORMAT(NotificationText));
OutStream := BinaryWriter.BaseStream;
RecordLink.MODIFY();
My parameters are
RecRef RecordRef
ObjectID Text 50
NotificationText2 Text 1024
Caption Text 50
and my variables are
OutStream OutStream
BinaryWriter DotNet ‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.System.IO.BinaryWriter
Encoding DotNet ‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.System.Text.Encoding
RecordLink Record Record Link
NotificationText BigText
My issue is on this line:
BinaryWriter := BinaryWriter.BinaryWriter(OutStream,Encoding);
I get this error: Unknown Type ''.
Does anyone know what is the issue?
Thanks guys
0
Comments
Thanks
Thanks!!
Amanda
Microsoft - Dynamics NAV
The code I've posted is working for NAV 2013 but it is not working for NAV 2009.
So, after spending hours trying to find a solution I actually gave up and used the comments instead of the notes. Much easier to manage.
Still interested to know if there is a solution though.
Cheers
It appears because Encoding doesn't have a constructor, NAV2009 cannot handle it.
|To-Increase|
Encoding := Encoding.Default;
to construct the Encoding variable.
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com
Sog, while I didn't get an unknown error in line Encoding := Encoding.GetEncoding(437);, I did receive an error when I originally pasted and copied the dotnet variable. GetEncoding was not an my Encoding C/AL Symbols menu. I entered manually to ensure it was pasted correctly, found what I had pasted was not my Processor Architecture type. Not sure if you reviewed already, but thought I would mention just in case.
Hope this helps!
Works in newer version but not 2009. Instead of calling it with a text variable, I made it a big text and assigned the text to it with addText, like this:
gFolderPath.ADDTEXT(edisetup."XML Source Document Folder");
After that it was OK to use it without error:
obj := fold.GetFiles(gFolderPath);