Reading/writing Notes with DotNet variables
mathieuk
Member Posts: 15
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
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
-
Does anyone have an idea?
Thanks0 -
Having the same issue.. Did you ever figure this out?
Thanks!!
Amanda0 -
We did provide a similar piece of code in NAV2013, codeunit 454 "Job Queue - Send Notification", where the Job Queue sends a notification to the user. The message format is in RTF, which includes one or two leading bytes of information about the message length.Bardur Knudsen
Microsoft - Dynamics NAV0 -
Sorry for the late answer.
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.
Cheers0 -
It seems I have the same error, but the line it errors out to is the following: Encoding := Encoding.GetEncoding(437);
It appears because Encoding doesn't have a constructor, NAV2009 cannot handle it.0 -
Try
Encoding := Encoding.Default;
to construct the Encoding variable.________________________________
Gunnar Gestsson
Microsoft Certified IT Professional
Dynamics NAV MVP
http://www.dynamics.is
http://Objects4NAV.com0 -
While I can't say this is the correct way... I have found a solution. I found the unknown type to be in line "BinaryWriter.BinaryWriter(OutStream,Encoding)", the unknown being the Variable: "Outstream - DataType Outstream". I created another variable, "Outstream1 Datatype DotNet - 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream" and modified the code as shown:
Note.CREATEOUTSTREAM(OutStream); OutStream1 := OutStream; Encoding := Encoding.GetEncoding(437); BinaryWriter := BinaryWriter.BinaryWriter(OutStream1,Encoding); BinaryWriter.Write(FORMAT(Notification)); OutStream := BinaryWriter.BaseStream;
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!0 -
Not entirely related but I got the unknown type '' error when trying to call a function with a string parameter.
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);0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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