Skip to content

Instantly share code, notes, and snippets.

@ernestasjuska
ernestasjuska / Code.al
Last active March 31, 2023 14:56
2023-03-31 BC, web services and active session problem
codeunit 50100 "MY Event Subscribers"
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::GlobalTriggerManagement, 'OnAfterGetDatabaseTableTriggerSetup', '', false, false)]
local procedure GetSetup(TableId: Integer; var OnDatabaseInsert: Boolean; var OnDatabaseModify: Boolean; var OnDatabaseDelete: Boolean; var OnDatabaseRename: Boolean)
var
ActiveSession: Record "Active Session";
begin
if TableId = Database::"MY Tag A" then
OnDatabaseInsert := true;
@ernestasjuska
ernestasjuska / Support for multiple BC versions at the same time idea.md
Last active March 10, 2023 14:23
Support for multiple BC versions at the same time idea

We currently have to use separate codebases to support different BC versions. This usually is done using Git branches.

Most of the code does not depend on platform version - for example table definition in BC22 is the pretty much matches one in BC19, same for other object types. The differences in code are only because platform has different functionality or application has different functionality. These differences could be processed using preprocessor directives but in current form they not really useful.

There needs to be a way to define several compiler configurations (maybe in app.json file), e.g:

  "targets": {
    "BC21CU5": { // for example some new functionality was added here
      "runtime": "10.0", // mandatory property
@ernestasjuska
ernestasjuska / Remove AL secondary keys.regex
Created November 10, 2022 10:15
Remove AL secondary keys
\n key\(Key(?!1;).*\n.*(\n .*)*\n \}
@ernestasjuska
ernestasjuska / Remove AL flowfields ands flowfilters.regex
Created November 10, 2022 09:57
Regex for removing flowfields and flowfilters
\n field\(.*\n.*\n( .*\n)* FieldClass = Flow(Field|Filter);(\n .*)*\n \}
codeunit 99999 "My Global State"
{
SingleInstance = true;
var
LastOperationId: Guid;
AllowSmth: Boolean;
local procedure UpdateState(CurrentOperationId: Guid)
begin
$XsdFileName = 'C:\Git\softera-baltic\eCom\eCom.DocuBank\camt.053.001.02.xsd'
$Prefix = 'tns'
$Tab = ' '
$ThemeName = 'Light'
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$Themes = @{
Dark = @{
@ernestasjuska
ernestasjuska / HelloWorld.al
Created September 14, 2020 11:32
BC16 On-Prem question
pageextension 50149 CustomerListExt extends "Customer List"
{
/* BC16 >> */
trigger OnOpenPage();
var
ApplicationObjectMetadata: Record "Application Object Metadata";
MyCodeunit: Codeunit "My Codeunit";
BlobStream: InStream;
UserAlCodeText: Text;