MyRapidi
MyRapidi

Search our Wiki

How to create an extension in Business Central / Publish SystemCreatedAt field in Business Central

SystemCreatedAt is one of the Data Audit Fields and is available on all tables but, for integration-purposes, you cannot access it via an ODATA connection because it needs to be published first. By inspecting the page, you can see this field and its corresponding value. In order to use this field in the production environment ( for integration purposes), you need to publish it by creating an extension in Visual Code via the AL Language extension for Microsoft Dynamics 365 Business Central.

Before you start, an easy way to obtain all the needed information is to get all the extension information from your sandbox environment. In any sandbox environment, you can publish any field and download the AL extension file. This .al file can be used to be uploaded into production.

Sign up for Business Central Sandbox and download the Visual Studio Code and the AL extension for Business Central. All steps are highlighted here - > https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-get-started.

  1. Open any page in your Business Central Sandbox environment and then go to Settings -> Design.
  2. Click on + Field and select the field that you need to add to your page.
  3. Drag and drop the selected field on the page where you want it to be displayed.
  4. Next, Click on Stop Designing and you will be asked to add the Extension Name for your extension and the Publisher ( the person who is actually creating it).Then, check the box for Download Code and click on Save.
  5. The AL package containing the extension code will be downloaded on your computer and will contain 2 files: app.json and the pageExtension.al. Now, this page will show the Created At field for all customers and can be used moving forward.
  6. Go to Visual Studio Code and simply copy-paste the files that you just downloaded from Business Central sandbox as follows: View -> Command Palette -> AL:Go!
  7. You will be prompted to set up a new project and the default name will be suggested but you can change it accordingly. Then press Enter to confirm.
  8. Next, you will be asked to select the target platform. Note: For Business Central cloud, it’s recommended to use the latest version from the list.
  9. Next, you will be asked to select the server. For cloud Business Central, you need to select Microsoft cloud sandbox.
  10. Into the HelloWorld.al copy-paste the content from the .al file that you downloaded earlier ( in my case, it’s the file called PageExtension50001.PageExt.al).And into app.json copy-paste the content from the downloaded file called app.json.
  11. Important: Make sure that you select the correct ID ranges for your extension. Once you indicate which would be your specific range, those IDs will be reserved for page extensions. And check sure that your launch.json contains the correct sandbox connection ( such as the environment name,etc).

  12. Once you are done with the above, click on View -> Command Palette -> AL: Package so you can compile everything. Afterwards, you will get the message 'Success:The package is created' and the package will be available for you under AL/ALProject8 folder.
  13. Install the extension into the production environment: Go to Settings -> Advanced Settings.
  14. Click on Extensions.
  15. Click on Manage -> Upload Extension.
  16. Click on Select .app file and upload the extension from your folder ( it’s the file with the .app extension that was generated after you’ve compiled everything in Visual Code) and then click on Deploy.
  17. Once the status shows Completed, then the installation has been successfully completed and you will be able to see the SystemCreatedAt field displayed on your Customer page.