Check Valid Zip Code

 

Hey Friends,

This Post is all about validating a proper Zip Code. Just 2 3 lines of code needed and you can validate your zip code. So below is the line of code that you just need to write.

 

 

 

 

 

 

 

//RWN
IF NOT Regex.Match(ZipCode, ‘^\d{5}$’ ).Success THEN
EXIT(FALSE)
ELSE
EXIT(TRUE);
//RWN

Regex           DotNet                  System.Text.RegularExpressions.Regex.’System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

CHEERS

Advertisements

Handle DateTime – Use DotNet Variable

 

Hey Friends,

Calculating exact Day, Time, No of Month in a Day, Number of days in a Year, Day of the Week and many more has always been a challenging point while writing code in NAV. Though you can manage to achieve this but anyhow you end up with many lines of code. But just twisting your code a little bit with some DotNet variable will bring you a broad smile in your face with just a single line of codes. For an example have a look into the below screenshot.

Capture

Just have a look on the above piece of code. Outcome is exactly the same what you are thinking. And here is the output

Capture1

Below is the description of the DotNet Variable used for the above case. I will recommend each and everyone to have a look on this and explore as it consists of a lot of Methods which can be of great help to you in your daily life as a NAV Programmer.

DotNetDateTime – DotNet – System.DateTime.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

Append String – Use DotNet Variable

 

Hey Everybody,

As a Developer there many scenario comes up where we need to append a text value. This kind of needs do comes up when we need to maintain a certain string length. As a common NAV Developer we use to write the below piece of code.

Capture

Replacing the above piece of code with some DotNet variable will literally make you shock as far as the Performance  & Optimization is concerned. Have a look on the below code.

Capture1

If you will calculate the Time taken by the above piece of codes then you will find that the second is 5 to 10 times faster then the first one. For e.g if First one takes 49 Sec 256 Milliseconds then the Second one will take just around 20 Milliseconds.

StringBuilder – DotNet – System.Text.StringBuilder.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

String Comparison – Use DotNet Variable

 

Hey Friends,

I guess many Developers might have had faced this Issue, Whenever we used to compare a Text variable in CAL Coding something like –

Capture1

 

 

 

 

We do face Issues like System is not giving Error even CalTextVariable contains a Blank value. Majority times this Issues comes when there is an Integration between NAV and some .NET Portals. Reason behind this issue is, A NULL value is never considered as a Blank value OR even you can say the White Spaces. So this Line of Code is never a Full Proof solution to handle these cases.

But Instead of the above Line of Code If we just Introduce a .Net Variable and write below line of Code then this turns out to be Full Proof Solution.

Capture

This Piece of Code will handle each Probability that might ever we skip while Coding.

DotNetStringVariable – System.String.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

CalTextVariable  – CAL Text Variable.

CHEERS