Please enable JavaScript.
Coggle requires JavaScript to display documents.
Introduction to the basics of AL: you can manipulate data, and the…
Introduction to the basics of AL:
you can manipulate data, and the statements and functions are able to read, write, and change data in the Business Central database.
object type in AL: (Table, Page, CodeUnit, Report, and so on)
Event triggers or Procedure triggers:
Every object type in AL (Table, Page, CodeUnit, Report, and so on) has event triggers, and their names start with On, for example OnInsert, OnModify, or OnDelete.
custom procedures:
You can also write your own custom procedures in an object, and
these custom procedures will be accessible in the object by Procedure triggers
. These custom functions are called Procedures
The Rec and xRec variables: are examples of system-defined variables. Rec gives access to the current record, and xRec gives access to the previous record (for example before an update occurred).
In general, write the code in codeunits instead of on the object on which it operates.
In general, write the code in codeunits instead of on the object on which it operates. This promotes a clean design and provides the ability to reuse code. It also helps enforce security. For example, typically users don't have direct access to tables that contain sensitive data, such as the General Ledger Entry table, nor do they have permission to modify objects.
If you put the code that operates on the general ledger in a codeunit, give the codeunit access to the table, and give the user permission to run the codeunit, then you won't compromise the security of the table and the user will be able to access the table.
If you must put code on an object instead of in a codeunit, then put the code as close as possible to the object on which it operates. For example, put code that modifies records in the triggers of the table fields.
collections
In AL, you start counting at one (1) for an array, while other programming languages, like Java, C#, and so on, usually start counting at zero (0) for the first element of an array.
variables
When a variable is created in memory, it is initialized, meaning that the variable gets a default starting value before you assign a value to this variable. This default value depends on the data type of that variable.
For variables with a numeric data type, a value of zero will be used to initialize. String variables will be initialized with an empty string. A Boolean variable has a default value of false.
The protected keyword:
can be used to make variables accessible between tables and table extensions and between pages and page extensions.
EVent
2 ways of subscribe to a table event:
use codeunit
table extension.
refer to
https://www.youtube.com/watch?v=04T2pAnXjGQ&list=PL1FESh9FqyhQxkZXYYp1X1tTpXf3-9iSR&index=17
timeline 1:18 to 1:28
Access REST API Service
You can't create a field in a table of an HTTP data type, but you can create variables in code.
The available classes are:
HttpClient
HttpContent
HttpHeaders
HttpRequestMessage
HttpResponseMessage