Copy the script and execute it - Your AL code will be ready in no time!

Copy the script and execute it - Your AL code will be ready in no time!

Transitioning from C/AL to AL code can be challenging. This blog simplifies the conversion process directly from VS Code, helping avoid common errors that occur due to incorrect property syntax and extensive manual corrections.

Setting Up Your Environment

First, create these temporary folders to keep your files organized:

  • C:\temp
  • C:\temp\AL
  • C:\temp\CAL
  • C:\temp\Delta
  • C:\temp\Split

Second,

  • Install specific upgrade database application version
  • Database Cronus - base version : Cronus database with Specific CU.
  • Database Custom - Modified database where you want to upgrade
  • BC14 latest Version - Txt2AL supports only in BC 14 latest CU.
  • Lock the objects which you want to upgrade or convert to AL.

Copy Script
Set-ExecutionPolicy RemoteSigned

#Import the module for the Export-NavApplicationObject Cmdlet

Import-Module "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client\Microsoft.Dynamics.Nav.Ide.psm1"

#Import the module for the Split-NavApplicaitonObjectFile Cmdlet

Import-Module "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\130\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1"

#Export objects from database Demo Database NAV (13-0)

Export-NAVApplicationObject -DatabaseName 'Demo Database NAV (13-0)' -Path 'c:\temp\CAL\StandardObjects.txt' -DatabaseServer 'FL-SQL-3' -ExportToNewSyntax -Filter 'Locked=1'

#Export objects from database D365BC_CUSTOM

Export-NAVApplicationObject -DatabaseName 'D365BC_CUSTOM' -Path 'c:\temp\CAL\ChangedObjects.txt' -DatabaseServer 'FL-SQL-3' -ExportToNewSyntax -Filter 'Locked=1'

# Create deltafile to make table extensions and page extensions
# export objects files as text from the develelopment environment
# Export both standard ojbects and changed objects

Compare-NAVApplicationObject -DeltaPath 'C:\Temp\Delta\' -ModifiedPath 'c:\temp\CAL\ChangedObjects.txt' -OriginalPath 'c:\temp\CAL\StandardObjects.txt' -ExportToNewSyntax

#Split the original source files to use it for comparision

Split-NAVApplicationObjectFile -Source 'C:\temp\CAL\StandardObjects.txt' -Destination 'C:\temp\CAL\Std'
Split-NAVApplicationObjectFile -Source 'C:\temp\CAL\ChangedObjects.txt' -Destination 'C:\temp\CAL\Custom'

# create the .al file

$getTxt2Alexe= "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client\Txt2Al.exe"

& $getTxt2Alexe --source 'C:\Temp\Delta\' --target 'C:\temp\AL' --extensionStartId 50000 #--objectFileNamePattern {id}.{name}.{type} --extensionObjectFileNamePattern {id}.{targetName}.{type}

#To get the file name from the specfic folders , this helps you to prepare Spreadsheet.

Get-ChildItem -Path "F:\temp\Src" -File -Name
        


Azeez Oyebowale

Certified Technical Consultant ( Business Central) | Microsoft 365 Finance & Operation Developer & Entrepreneur | Tutor | Content Creator | Helping Businesses Streamline Processes & Maximize Efficiency

7 个月

Great content

回复
Srinivasan Kanagaraj

Microsoft Dynamics | Great Plains |Business Central

7 个月

Very informative Senthil Kumar Varatharajan how to take care about about the standard object custom

要查看或添加评论,请登录

Senthil Kumar Varatharajan的更多文章

社区洞察

其他会员也浏览了