Kine's Info

What I found and what I know about Microsoft Dynamics NAV

NAV 5.0 Preview - Part 1 - The C/AL

In this article, I will describe you what is new in C/AL and C/Side in Microsoft Dynamics NAV 5.0. It will be brief, but I do not like long texts about nothing. Let's go!

New C/AL keywords:

  • COMMANDLINE  - Use this function to return a list of the parameters used to start Microsoft Dynamics NAV . The command will return something like "database=xyzco,id=NAV50,NTauthentication=0" - it means all parameters used when starting NAV client.
  • APPLICATIONPATH - Use this function to return the path to the directory where the executable file for Microsoft Dynamics NAV is installed. MAX 255 chars!!!
  • TEMPORARYPATH - Use this function to return the path to the directory where the temporary file for Microsoft Dynamics NAV is installed.
  • ISSERVICETIER - Use this function to find out whether the code you are executing is running on the new Dynamic NAV three-tier architecture or on the old two-tier architectureThis is the first command connected with NAV 5.1 three-tier architecture!
  • VARIABLEACTIVE (Automation) - Use this function to determine if a variable, such as field or a control, is active or inactive. I personally have no idea when I will need that. I am using ISCLEAR now. But may be in the  future...
  • [Ok :=] UPLOADINTOSTREAM(DialogTitle, FromFolder, FromFilter, FromFile, NVInStream) - Not described in on-line help yet. In my opinion it is function prepared for NAV 5.1, for service tier to be able to transfer files between client PC and service-tier (local file for service tier is not anymore local file for client, this will be used in connection with ISSERVICETIER command).
  • [Ok :=] DOWNLOADFROMSTREAM(NVInStream, DialogTitle, ToFolder, ToFilter, ToFile) - see UPLOADINTOSTREAM
  • [Ok :=] UPLOAD(DialogTitle, FromFolder, FromFilter, FromFile, ToFile) - see UPLOADINTOSTREAM
  • [Ok :=] DOWNLOAD(FromFile, DialogTitle, ToFolder, ToFilter, ToFile) - see UPLOADINTOSTREAM
  • KEYGROUPENABLE(Groupname) - Use this function to enable a key group. - Yes, now you can enable and disable keygroups through C/AL code.E.g. you can use it in report running once per year, which need some special keys to run faster.
  • KEYGROUPDISABLE(Groupname) - Use this function to disable a key group.
  • KEYGROUPENABLED(Groupname) - Use this function to check whether or not a specific key group is enabled.
  • GETLASTERRORTEXT - Use this function to return the text that was contained in the last error message displayed by the system. Coolest new command in version 5.0 for me! Now, you are able to find which error was called when calling codeunit in IF-THEN statement! Used for example when running Cost Adjustment batch to prevent stopping the batch on first error! Now the job continues after the error and you see the error in the report!
  • CLEARLASTERROR - Use this function to remove the last error message from memory.
  • [ID] := Rec.ADDLINK(URL[, Description]) - Use this function to add a link to a record. Connected to the new Link functionality in v5.0. You are able to add any URL to any record in NAV. User can see the URLs and can easily open the documents. I will describe this module in some upcomming part.
  • Rec.DELETELINK(ID) - Use this function to delete a link that has been added to a record in a table.
  • Rec.DELETELINKS - Use this function to delete all of the links that have been added to a record.
  • Rec.COPYLINKS(FromRecord) - Use this function to copy all the links from a particular record.
  • Ok := Rec.HASLINKS - Use this function to find out whether or not a record contains any links.

This is the list of all new commands I found in the NAV v5.0 for now. I hope, that you are excited to see some commands from this list. The text is copied from On-line C/AL help available with this beta version.

 

New features in C/SIDE

 

New Properties

  • Form.SourceTableTemporary(Yes/No) - No description - if set to Yes, Rec will be temporary table! You do not need to modify OnFindRecord and OnNextRecord anymore!
  • Form.LinksAllowed - settings connected to the new Link functionality, which can be disabled per form...

Indenting

  • For all C/AL developers - now you can indent whole block of code just with selecting the lines and pressing Tab key (or Shift+Tab to unindent)!

This is what I found in this Beta version for now. May be there are some new things which are still hidden for me, but what I found I found as usefull. I hope that you as well.

 

I do not know, what will be in next Part of the preview yet, may be something about the Link functionality.

  • Kamil, great Blog.

    Congratulations on being the first person anywhere to be allowed to make this public. Hopefully people can post their opinions here.

    Indenting About time, they had that in the DOS version, and dumped it in windows. This may lead to cleaner code.
  • Oh and Ahmed is going to love

       GETLASTERRORTEXT

    It was on his hot list of Convergence questions that I didn't get an answer for.
  • Thanks Kine, for this information.
    GETLASTERRORTEXT will be very useful in Sales Posting Batch too.
    The block indenting was overdue. I don't know how many hours altogether I have spent in the last years indenting line by line...  
  • Thanks Kine,

    I only managed to get an hour or so overview about 4 months ago. Looked intresting.

    Have you had a try at converting to c#? The rsulting code looked mind bogglig, certainly put me off modifying it in VS05 :-)

    /TH
  • Lol david. Yes, I've done too many integration and have so far just given generic error. It sucked. I can't wait to go home and take a look at the CD.

    with Form.SourceTableTemporary(Yes/No)

    does it mean that we can use Currform.SETSELECTIONFILTER will work with temporary records?
  • TonyH: I have just 5.0, where the compilation into C# is not available. Where you got this 5.1 version?

    Ara3n: I will try and I will post the result...
  • Hey Kine,

    I haven't got a copy of 5.1 just a demonstration.
  • That demonstration though was just them showing the process, it was not recommended, and from the way they have been talking, I suspect that they will make it very difficult for anyone that does do this.
  • I think they said that once you push it across to C# there's no going back. I can't remember the conversation completely.

    But just makes me wonder.... Why bother? What's the long term meaning?

    Its easier to change it in C/Side that VS.
  • Its not what's easier that matters. I had a developer working for me once that refused to work in anything but Delphi. He even wrote a C/FRONT Delphi wrapper, and wrote code in Delphi. I just sacked him, there was no chance to ever convince him to do it the Navision way.

    Same is happening now with C#, of the over 1,000,000 Navision users, there is a very very small percentage (I would guess less than 0.1%)  that want to develop in C#, but they are vocal, and want C# even if they don't know why.
  • It's not just about existing developers, but future develoeprs, and customers. Telling them that they can use C# is a big plus.
  • Sounds like time for a poll to me ;-)
  • delicate answers i like it