top of page
Daniel Gorski

How-To Solve your issues after TXT2AL

Aktualisiert: 4. Jan. 2022

or should I really run through all my files and convert the variables?


What's the case?


You convert your old C/AL Code and make them AL ready, right?

This is how you should do it:

  1. Export your C/AL-Objects as txt-File

  2. Split your Objects separately (I will provide a powershell script soon)

  3. run this e.g. in cmd: cd C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client txt2al.exe --source="C:\Install\Source" --target="C:\Install\Target"

Get your converted files and import them into your repo in VC Code:

And as you can see, your variables are not recognized.


You could use a Regular Expression:

"(\d*)"

and replace it with:

$1


or you could even us this powershell script or how I call it "txt2AL Beautifier":


This Powershell script works with a dictionary, which you can easily extend:

And it will iterate thorugh all given *.al files to convert these variables correctly.



$mapping = @{
 'Record "3"' =  'Record "Payment Terms"';
 'Record "4"' =  'Record "Currency"';
 'Record "5"' =  'Record "Finance Charge Terms"';
 'Record "6"' =  'Record "Customer Price Group"';
 'Record "7"' =  'Record "Standard Text"';
 'Record "8"' =  'Record "Language"';
 'Query "7300"' =  'Query "Lot Numbers by Bin"';
 'Query "7301"' =  'Query "Whse. Employees at Locations"';
 'Query "7345"' =  'Query "Avail Qty. (Base) In QC Bins"';
 'Query "9060"' =  'Query "Count Sales Orders"';
 'Query "9063"' =  'Query "Count Purchase Orders"';
 'Query "9150"' =  'Query "My Customers"';
 'Query "9151"' =  'Query "My Vendors"';
 'Query "9152"' =  'Query "My Items"';
}


$regexescape = $mapping.keys | ForEach-Object {[System.Text.RegularExpressions.Regex]::Escape($_)}
$regex = [regex]($regexescape -join '|')

Get-ChildItem $PSScriptRoot -Filter *.al  | Foreach-Object {
 $values = { $mapping[$args[0].Value] }
 $incomingfile = [System.IO.File]::ReadAllText($_.FullName)
 $incomingfile = $regex.Replace($incomingfile, $values)
 Set-Content -Path ($_.DirectoryName + $_.BaseName + '_out.al') -Value $incomingfile
}

Get the full file here:



Have Fun :)

834 Ansichten0 Kommentare

Aktuelle Beiträge

Alle ansehen

Comments


bottom of page