Posts

C/AL to AL: The Complete Migration Cheat Sheet (2026 Edition)

If you learned C/AL in the Dynamics NAV era, the good news is that most of your knowledge still applies. AL , the language of Microsoft Dynamics 365 Business Central, kept the core concepts — tables, pages, codeunits, triggers but modernized the syntax and moved everything to an extension-based model. C/AL and the classic C/SIDE environment were retired back in Business Central version 15 (2019), and as of 2026 we are already 13 major versions into the fully AL-based world. This cheat sheet maps the most common C/AL patterns to their AL equivalents so you can migrate old code (or old skills) quickly. 1. The big picture: what changed Concept C/AL (NAV) AL (Business Central) Development tool C/SIDE (Object Designer) Visual Studio Code + AL Language extension Customization model Modify base objects directly Extensions only never modify the base app Object files Stored in the database Plain-text .al files in a project, version-controlled with Git Deployment Import .fob / .txt ...

FOR Loop

FOR Loop or FOR Statement In Microsoft Dynamics NAV Definition FOR loop is a repetitive statement or loop, is used when we need to execute the code a predetermined number of times.  FOR Loop in Microsoft Dynamics NAV, C/AL having mainly 2 types FOR .. TO Loop FOR .. DOWNTO Loop FOR .. TO Loop In the case of FOR .. TO Loop the value checking is incresed format and when the value reach the condition wrong then exit loop. Syntax of FOR .. TO Loop: -------------------------------------------------------------- FOR Control Variable :=   Start Value TO End Value DO Statement -------------------------------------------------------------- Here Control Variable must be a variable type of Boolean, Date, time or any numeric type. The Start value and End Value must be either expressions of same data type. For Example: =========================================== FOR i :=1 TO 5 DO     Result := Result + 5; =========================================== In this programming codes works in a manner that...

LOCAL FUNCTIONS AND VARIABLES

LOCAL FUNCTIONS AND VARIABLES Local Functions A local function is a function that can be called in the object in which it is defined. Any function that not be defined by local function called from other objects as well as the objects from which its defined. Local Variables A local variable is avariable whose scope is limited to single function. This means that in this function trigger code, a local variable can be used like any other variable. If the name of a local variable is reffered outside of the function in which it is defined, syntax error will result.

FUNCTION PARAMETERS

FUNCTION PARAMETERS IN MICROSOFT DYNAMICS Function parameter is one or more variables or expressions that are sent to the function through a function call. These parameters provided for function information also can able to modify that information. If there is more than one parameter, the parameters will be sepearated by commas. There are mainly 2 types of parameter passing occur Pass By Value Pass By Reference Pass By Value :- In this type of parameter passing only pass some values only. If we change thse values then it will not affect in the parent trigger or values. That is once pass the value it will not affect any kind of changes in the parent method, its only passing the value. Pass By Reference :- In this kind of parameters its pass like reference of the variable, sometimes called name of the variable. Whenever we change the value of these variables it will affect the parent trigger also. Because in this type the computer knows the exact storage space of that variable or paramet...

FUNCTIONS IN MICROSOFT DYNAMICS

FUNCTIONS IN MICROSOFT DYNAMICS Definition Functions are named portions of a program, some times called as Subprogram or Subroutine. When a function is called from a set of programming code then current programming code is suspended and continued with a trigger code. And after the completion of that trigger the program control return to the origin.  A function can be used as expression also For example: TotalCost := Qty * CalculatePrice In this code CalculatePrice is one function that calculate the price and after the calculation it return some value based upon that further programming codes executes. Built In Functions In Microsoft Dynamics C/SIDE programming using some built in functions also. These programming codes cannot be viewed by the users and it cannot be modified. Some of the built in functions are as follows MESSAGE :- Displays a message on the screen. MAXSTRLEN :- Return defined legth of string variable. COPYSTR :- Returns part of a string CLEAR :- Clears the passed in v...

CASE

CASE Loop or Statements CASE Loop or statements is a conditional statement.  Like IF loop or statement these also works in the manner that once the statement is true then some statements are executed other wise the else part will be executed. But in the case of CASE we can consolidate muliple levels of IFloops in one CASE. Some programming languages like C its called as SWITCH - CASE loop but in Navision or Microsoft Dynamics NAV we called this as CASE only. Syntax of CASE  -----------------------------------------------------------         CASE Expression OF                Value Set 1 : Statement 1;                Value Set 2 : Statement 2;                  ...                Value Set n : Statement n;               ELSE Statement n+1;          END   ----------------------------------------------------------- A sample program for the CASE is as follows ==============================================================      CASE Color OF            Color :: Orange:                        ...

WITH Loop / Statement

WITH Loop / Statement WITH Statement or loop is used to make record variables easier.  Record variable is a complex datatype with one variable we can store multiple values like arrays. Each record having different fields and each of these fields can able to store different data types also. These fields are separated by the ' . ' or dot sign. If a customer record having field named Name then it can be specified like customer.Name Syntax Of WITH Loop Suppose we having three fields names name, address and City then it can be specified in the recod named customer as folows      customer.Name := Txt[1];      customer.Address := Txt[2];      customer.City := Txt[3]; We can sort these kind of representation in the system different way so that we can minimise the number of codings that syntax of WITH Loop is as follows ----------------------------------------------------------------------------            WITH Record Variable DO Statement ---------------------------------------------...

REPEAT - UNTIL Loop

REPEAT - UNTIL Loop or Statement In Microsoft Dynamics NAV C/AL Definition REPEAT - UNTIL Loop is a repetative loop, is used for programmes having one or more statements to be executed until some condition. Syntax OF REPEAT - UNTIL Loop --------------------------------------------------- REPEAT Satements UNTIL Boolean Expression --------------------------------------------------- This works in a manner like that it will work the statements until the Boolean Expression is true. The difference Between WHILE-DO loop is that the REPEAT - UNTIL Loop will execute atleast one time and then only it will check the Boolean expression true or false. But in the case of WHILE-DO loop only execute the code when a particular condition is true. For Example: ======================================= REPEAT i :=  i + 1; Total Sales := Total Sales + Sales[i]; UNTIL Sales[i]=0; ======================================= The abow example works in a manner like that it will execute the statement once after tha...

WHILE .. DO Loop

WHILE .. DO Loop or Statement In Microsoft Dynamics NAV C/AL Definition The WHILE .. DO Loop is a repetitive statement or loop, is used in the program where a certain code is to be executed as long as some condition is true. Syntax Of WHILE .. DO Loop ----------------------------------------------------- WHILE Boolean Expression DO Statement ----------------------------------------------------- This is simpler than the IF loop. In the case of  WHILE .. DO Loop the system check continously the boolean expression become true then the statement between BEGIN and END execute otherwise move to next statement. For Example: ================================================== WHILE Sales[i+1] 0 DO BEGIN      i := i + 1;      Total Sales :=  Total Sales + Sales[i]; END; ================================================== This is work in a manner like that check every time the Sales[i+1] 0 and if the condition is true then execute the statement between BEGIN and END other wise execute after t...

Repetitive Statements or Loop

Repetitive Statements or Loop Repetitive Statements or Loops are using when we want to execute one statement or more than one statement multiple times. In the case of IF loop it will work only for one time execution only. So if the user need to execute a statement more than one times based upon some condition.  All the repetitive statements are works in a manner like that it will work repetedly until one condition satisfy and if that condition appear then it moves the control to next programming satement after the repetitive statements. And in the case of repetitive statements always having initialize variable and increment values will appear.  Some of the Repetitive statements are IF Statement, WHILE .. DO, REPEAT .. UNTIL etc.

CLEAR

CLEAR() In Microsoft Dynamics NAV C/AL CLEAR() is used to clear the Variable. The sysntax of CLEAR()  is  CLEAR(Variable); CLEAR () clears the variable in the manner like if the Variable is Integer then the Variable value reset to zero. And if the variable is String then the Variable value reset to empty. For Exapmple, If you want to reset a Result variable that stores the sum of previous calculation then you have to mension  CLEAR(Result); After executing this line the calue Result goes to zero. So the CLEAR () is most usable function in the good C/AL programing.

Syntax Of Arrays

Syntax Of Arrays In Microsoft Dynamics Synatax An array have to define in the following format of syntax only in the Navision (Microsoft Dynamics NAV) C/AL. Identifier   [Index Expression1] , [ Index Expression 2] , etc . The 'Identifier' is the Variable identification of an array and this need to include any types of arrays. Only the difference occur in the 'Index Expression' area only. ie, If we need Single dimension array then we need only Index Expression1.  In that case following will be the sysntax Identifier   [Index Expression1] Exapmple : A[3] In the case of Two dimensional  array we have to mension upto Index Expression2.  And in the case of Three Dimensional Arrays we have to mension Index Expression1,  Index Expression2, Index Expression3. How to assingn values to the Arrays? To assign values to the array element 4 as 50 then you have to mension in the following format. A[4] := 50;

Arrays

Arrays In Microsoft Dynamics NAV Definition: Arrays are special type of variables that have more functionality than the simple variable or normal variables.  An Arrays is a complex variable that actually holds group of variables and these groups is defined once with a single identifier and a single datatype. For Example: Identifier : QuantityArray Data Type: Integer Diffrent Terms of Arrays Index Index is used to refer to single element in an array Element An element is a single variable in an array. To access the 5 element in the array of QuantityArray, you have to specify like QuantityArray[5] Dimension An array can be specified in different dimensions. In the abow example QuantityArray[5] is a type of one dimensional array. Array dimension can be one or more. But one dimension arrays more simpler than multidimension arrays. For specifying the Complex datas we are using Muli dimensional arrays.

Combound Statements

Combound Statements In Microsoft Dynamics NAV Combound Statements are statements that can be used to represent multiline statements in the IF, WHILE etc like statements. Sysntax for combound statements are BEGIN Statement1 {; Statement2} END For example : ===================================== IF Quantity 0 THEN      BEGIN               UnitPrice := ExtendedPrice / Quantity;               TotalPrice := TotalPrice + ExtendedPrice;      END; =====================================

Comment

Comment In Microsoft Dynamics NAV What is a Comment? Comment is the useful information to identify or represent a programming code. The comment statements are not executable so we can comment the programming codes that no need to execute also. Types Of Comments Mainly 3 types of comments available in the Microsoft Dynamics NAV C/AL. Single Line Comment  Block Of Comment Nested Comments Single Line Commen ts :- Single line comments are types of comments that can used to comments single line of codes. In this case, this single line comment ignore by the compiler. The Syntax used is '//'. ie, if we are placing // in any of the program codes then after that text is consider to be comment. For Example: ================================================ //Sample code for Comment showing adding two numbers A := B + C; ================================================ Block Of Comment :- Block comments are comments that allow multiline comment. Block comments start with '{' br...

EXIT Statement

EXIT Statement In Microsoft Dynamics NAV  EXIT statement is a type of statements that used for skip following program  trigger for avoiding errors or other purpose. Whenever an EXIT statement was there the program quit further moving the codes of that trigger and the control backs to the objects. For exaple consider the following codes ============================================= IF Quantity = 0  THEN   EXIT; Unit Price := Total Price / Quantity; ============================================= This statement works in a manner that once the Quantity value will be '0' then the program skip the codes preceding that for avoing the division by zero error.

IF - THEN And IF - THEN - ELSE Satement In Microsoft Dynamics NAV

IF Satement In Microsoft Dynamics NAV IF Statement is the most commonly used conditional statement that work based upon the statement is TRUE or FALSE. Conditional Statements works like first check one condition and based upon the result of this condition further flow of the program happened. Microsoft Dynamics NAV(previously Navision) language C/AL is used other conditional statements too. If statement or IF loop is used execute a code when a purticular statement is TRUE only and some case its used to execute some statements when the statement is FALSE too. There are mainly 2 types of IF statement specifications IF - THEN Syntax IF - THEN - ELSE Syntax IF - THEN Syntax : - In this type of IF statements you have to use following type of syntax IF boolean expression THEN  statement This statement works in a manner that first the Boolean expression is evaluated and if the value is TRUE then the Statement excuted and if the Boolean expression is FALSE then the statements after the IF sta...

Form Designing And Executing In Microsoft Dynamics NAV

Image
Form Designing And Executing In Microsoft Dynamics NAV(Navision) Using C/AL By this topic i will tell how to design a Microsoft Dynamics NAV Form  Designing and Excetions of a simple program.  There are mainly 5 steps we have to care when we design a Simple Form without using table in the Dynamics NAV.  Designing Form Defining Variables Assigning Variables to the designed form objects Create a programe code to excute the form Run the form Designing Form :-  For design a form you have to first goto the Tools -> Object Designer -> Form . Then click on the New Button. Select   c reate a blank form and press ok . After opening that select from the menu View -> Toll Boox ,  View ->Font ,  View -> Color .                                                                                                                                                                                                                                                                                  ...

Logical and Relational Operators & Expressions

Logical and Relational Operators In The Microsoft Dynamics NAV C/AL Logical and Relational operators are always result in a boolean value ie, either TRUE or FALSE. Relational Operator Relational operator is used in the relational expressions to test a relationship between the term preceding it and the term following it, resulting in a boolean value. These operators are listed below = (equal to) IN (Included in set) > (grater than) (not equal to) Logical Operator Logical operator uses one or two Boolean terms in a logical expression. The logical binary operators are AND, OR and XOR (exclusive or). The one logical unary operator is NOT.

Expressions

Expressions In Microsoft Dynamics C/AL Definition An Expression is a formula telling the computer how to generate the desired value.Like a variable and a constant, an expression has a type and value. A expression must be evaluated at run-time in order to determine its value. Although a constant's value is known at all times, a variable value is determined at run time, the  system must look it up in memory. Examples Quantity * DirectUnitCost Expressions Function Calls Expression function call are the type of function calls that calls from the expression itself. If you try to assign too many characters to a string variable, you will get a runtime error. How this overcomed, since the error doesnot occur until the program is running? One of the method to overcome this is to design your program such that this error could never happen. In some cases using another method.  MAXSTRLEN Function MAXSTRLEN function will tell you at runtime the maximum legth of a string that can fit in a variab...