Automating Prepayment Handling in Business Central – Part 2
In Part 1, we explored the core logic of handling prepayment invoices in Business Central using AL. In this part, we will dive deeper into the practical implementation, focusing on how prepayments are applied, invoices are generated, and item charges are assigned. This blog will break down the logic in a simplified, yet complete way. Why Automate Prepayments? In real-world business scenarios, companies often pay vendors before the invoice is fully posted. Handling these prepayments manually is tedious and error-prone: Our AL code automates this process: it creates purchase invoices, handles prepayment lines, applies payments, and ensures that item charges are correctly assigned. 1. Event Subscriber: Trigger After Posting Purchase Document The automation starts with an event subscriber that triggers after a purchase document is posted: [EventSubscriber(ObjectType::Codeunit, Codeunit::”Purch.-Post”, ‘OnAfterPostPurchaseDoc’, ”, false, false)]procedure OnAfterPostPurchaseDocHandler(var PurchaseHeader: Record “Purchase Header”)var Rec_PreppaymentLines: Record PrepaymentLinesandPayment; PurchInvoiceHeader: Record “Purchase Header”; VendorInvoiceMap: Dictionary of [Code[20], Code[20]]; VendorNo: Code[20];begin // Collect unique vendors Rec_PreppaymentLines.SetRange(“Purchase Order No.”, PurchaseHeader.”No.”); Clear(VendorList); if Rec_PreppaymentLines.FindSet() then repeat if not VendorList.Contains(Rec_PreppaymentLines.”Vendor No.”) then VendorList.Add(Rec_PreppaymentLines.”Vendor No.”); until Rec_PreppaymentLines.Next() = 0; // Process each vendor foreach VendorNo in VendorList do begin // Create or reuse invoice if VendorInvoiceMap.ContainsKey(VendorNo) then PurchInvoiceHeader.Get(PurchInvoiceHeader.”Document Type”::Invoice, VendorInvoiceMap.Get(VendorNo)) else begin PurchInvoiceHeader := CreatePurchaseInvoiceHeader(VendorNo); VendorInvoiceMap.Add(VendorNo, PurchInvoiceHeader.”No.”); end; // Handle prepayment lines Rec_PreppaymentLines.SetRange(“Purchase Order No.”, PurchaseHeader.”No.”); Rec_PreppaymentLines.SetRange(“Vendor No.”, VendorNo); if Rec_PreppaymentLines.FindSet() then repeat HandlePrepaymentLine(Rec_PreppaymentLines, PurchInvoiceHeader); until Rec_PreppaymentLines.Next() = 0; end;end; Key Takeaways: 2. Handling Prepayment Lines The HandlePrepaymentLine procedure ensures each prepayment is processed correctly: procedure HandlePrepaymentLine(var PrepaymentLine: Record PrepaymentLinesandPayment; var PurchHeader: Record “Purchase Header”)var PaymentEntryNo: Integer;begin // Unapply previous payments if any PaymentEntryNo := UnapplyPaymentFromPrepayInvoice(PrepaymentLine.”Prepayment Invoice”); if PaymentEntryNo = 0 then Error(‘Failed to unapply Vendor Ledger Entry for Document No. %1’, PrepaymentLine.”Prepayment Invoice”); // Create credit memo and invoice line CreateCreditMemoLine(PrepaymentLine, PrepaymentLine.”Prepayment Invoice”); CreatePurchaseInvoiceLine(PurchHeader, PrepaymentLine); // Assign item charges and post AssignItemChargeToReceiptAndPost(PrepaymentLine, PurchHeader.”No.”, PrepaymentLine.”Purchase Order No.”);end; Highlights: 3. Applying Payments to Invoice The ApplyPaymentToInvoice procedure ensures the invoice is linked with the correct prepayment: procedure ApplyPaymentToInvoice(InvoiceNo: Code[20]; PaymentEntryNo: Integer)var InvoiceEntry, VendLedEntry: Record “Vendor Ledger Entry”; ApplyPostedEntries: Codeunit “VendEntry-Apply Posted Entries”; ApplyUnapplyParameters: Record “Apply Unapply Parameters”;begin InvoiceEntry.SetRange(“Document No.”, InvoiceNo); InvoiceEntry.SetRange(Open, true); if InvoiceEntry.FindFirst() then begin VendLedEntry.SetRange(“Entry No.”, PaymentEntryNo); if VendLedEntry.FindFirst() then begin InvoiceEntry.Validate(“Amount to Apply”, InvoiceEntry.”Remaining Amount”); VendLedEntry.Validate(“Amount to Apply”, -InvoiceEntry.”Remaining Amount”); ApplyUnapplyParameters.”Document No.” := VendLedEntry.”Document No.”; ApplyPostedEntries.Apply(InvoiceEntry, ApplyUnapplyParameters); end; end;end; Benefits: 4. Assigning Item Charges Item charges from receipts are automatically assigned to invoices: procedure AssignItemChargeToReceiptAndPost(var PrepaymentLine: Record PrepaymentLinesandPayment; PurchInvoiceNo: Code[20]; PurchaseOrderNo: Code[20])var PurchRcptLine: Record “Purch. Rcpt. Line”; ItemChargeAssign: Record “Item Charge Assignment (Purch)”;begin PurchRcptLine.SetRange(“Order No.”, PrepaymentLine.”Purchase Order No.”); PurchRcptLine.SetFilter(Quantity, ‘>0’); PurchRcptLine.SetRange(“No.”, PrepaymentLine.”Item No.”); if PurchRcptLine.FindSet() then repeat ItemChargeAssign.Init(); ItemChargeAssign.”Document No.” := PurchInvoiceNo; ItemChargeAssign.”Applies-to Doc. No.” := PurchRcptLine.”Document No.”; ItemChargeAssign.”Item Charge No.” := PrepaymentLine.”Item Charge”; ItemChargeAssign.”Qty. to Assign” := 1; ItemChargeAssign.”Amount to Assign” := PrepaymentLine.Amount; ItemChargeAssign.Insert(true); until PurchRcptLine.Next() = 0;end; Outcome: To conclude, by implementing this automation: This code can save significant time for finance teams while keeping processes accurate and transparent. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com
Share Story :
PART 1 – Understanding the Core Logic Behind Automated Vendor Prepayments in Business Central
Managing prepayments can be challenging for businesses that work with multiple vendors on the same Purchase Order. In many industries, especially those that handle specialized procurement or complex supply chains, it is common for a single PO to include several lines that each involve a different vendor. This means every vendor has different payment terms, different prepayment requirements, and different financial workflows. A client in the gas distribution industry had this exact issue: each PO line belonged to a different vendor, and every vendor required a separate prepayment invoice, payment, and auto-application before goods could be received. Because of strict financial controls and vendor requirements, nothing could be posted or received until each prepayment was correctly processed and applied. Why Standard Business Central Was Not Enough Business Central supports prepayments, but only at the Purchase Order header level, not line by line.This means BC assumes the entire PO is for a single vendor, which is not always true in real-world scenarios. In addition, standard BC does not automatically: This forces users to manually: Thus, managing prepayments became a manual and error-prone process. As the number of PO lines increased, the amount of duplicated work increased as well, leading to delays, mistakes, and inconsistencies across the system. Our Solution – A Custom Prepayment Engine To solve this, we built a customized “Prepayment Lines” page where users can manage prepayments at the line level instead of the header level. On this page: This gives the user full control while keeping everything in one place. When the user confirms, Business Central automatically: All of this happens in a single automated process without requiring the user to manually open journal pages or vendor ledger entries. To conclude, this transformed a lengthy, manual workflow into a fully automated one. What previously took many steps across multiple pages and required careful tracking is now processed reliably with one action, saving time, reducing errors, and ensuring that goods can be received without financial delays. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com
Share Story :
Optimizing Inventory Operations with Microsoft Dynamics 365 Business Central
Managing inventory effectively is essential for any organization aiming to balance stock levels, minimize excess inventory costs, and ensure timely order fulfillment.Microsoft Dynamics 365 Business Central provides a range of tools that simplify and automate inventory control – helping businesses maintain the right stock at the right time. In this post, we’ll walk through the key features and planning tools available in Business Central’s Inventory Management module. Pre-requisite: 1. Access the Item List Page Start by opening the Item List page. This page offers a complete overview of all active items, including quantities on hand, reorder points, and categories. It serves as the foundation for any inventory planning activity. 2. Open an Item Card Select an item from the list to view its Item Card, where you configure how the system manages, replenishes, and forecasts that product. The setup on this page directly affects how purchase or production orders are generated. a. Configure Replenishment Method and Reordering Policy Under the Replenishment tab, you can define how stock for each item should be refilled when levels drop below a specific threshold. Replenishment Methods include: Lead Time:Set the expected number of days it takes to receive, produce, or assemble an item. This ensures the system plans replenishment activities in advance. Reordering Policies: b. Using Stock Keeping Units (SKUs) for Location-Specific Planning SKUs allow tracking of an item by individual location or variant, enabling businesses to manage stock independently across warehouses or stores.This approach ensures accurate availability data, reduces fulfillment errors, and supports better demand analysis for each location. c. Demand Forecasting The Demand Forecast feature in Business Central helps predict future requirements by analyzing past sales and usage patterns.Forecasts can be system-generated or manually adjusted to reflect upcoming promotions, seasonal variations, or expected demand spikes. d. Requisition (MRP/MPS) Planning The Requisition Worksheet supports Material Requirements Planning (MRP) and Master Production Scheduling (MPS). It automatically reviews forecasts, current stock, and open orders to suggest what needs to be purchased or produced. The system lists recommendations such as item names, quantities, and suppliers.Once reviewed, click Carry Out Action Messages to create purchase or production orders directly — saving time and minimizing manual work. e. Aligning with Sales Orders When a Sales Order is entered, Business Central dynamically recalculates availability.If demand exceeds what was forecasted, the system proposes additional purchase or production orders to prevent shortages and maintain customer satisfaction. To conclude, Dynamics 365 Business Central simplifies inventory control by automating procurement, forecasting demand, and synchronizing stock levels with actual sales.By using replenishment rules, SKUs, and requisition planning, businesses can improve inventory accuracy, reduce costs, and deliver orders faster – all within a single integrated ERP system. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudFronts.com
Share Story :
Flexible Line Display in Purchase Order Report – Business Central RDLC Layout
When working on report customizations in Microsoft Dynamics 365 Business Central, one common challenge is maintaining a consistent layout regardless of how many lines are present in the data source. This situation often arises in reports like Purchase Orders, Sales Orders, or Invoices, where the line section expands or contracts based on the number of lines in the dataset. However, certain business scenarios demand a fixed or uniform presentation, such as when a client wants consistent spacing or placeholders for manual inputs. This article demonstrates how you can achieve this flexibility purely through RDLC layout design – without making any changes in AL or dataset logic. Business Requirement The objective was to design a Purchase Order report where the line area maintains a consistent structure, independent of how many lines exist in the actual data. In other words, the report layout should not necessarily reflect the dataset exactly as it is. The idea was to ensure visual uniformity while keeping the underlying data logic simple. Proposed Solution The solution was implemented directly in the RDLC report layout by creating two tables and controlling their visibility through expressions. There was no need to align them in the same position one table was placed above the other. RDLC automatically handled which one to display at runtime based on the visibility conditions. Table 1 – Actual Purchase Lines Displays the real data from the Purchase Line dataset. Table 2 – Structured or Blank Layout Displays a predefined structure (for example, blank rows) when fewer lines are available. This design ensures that whichever table meets the visibility condition is rendered, maintaining layout flow automatically. Implementation Steps 1. Add Two Tables in the RDLC Layout 2. Set Visibility Conditions To control which table appears at runtime, open each table’s properties and go to:Table Properties → Visibility → Hidden → Expression Then apply the following expressions: For Table 1 (Actual Purchase Lines) =IIF(CountRows(“DataSet_Result”) <= 8, True, False) Hides the actual data table when the dataset has fewer rows. For Table 2 (Structured or Blank Layout) =IIF(CountRows(“DataSet_Result”) > 8, True, False) Hides the structured or blank table when enough data rows are available. Note: The number “8” is just an example threshold. You can set any value that fits your design requirement. Result At runtime: The RDLC engine handles layout adjustment, ensuring the report always looks uniform and visually balanced – without any need for AL code changes or temporary data handling. Advantages of This Approach Benefit Description No AL Code Changes Achieved entirely within RDLC layout. Upgrade Friendly Dataset and report objects remain unchanged. Automatic Layout Flow RDLC adjusts which table is displayed automatically. Professional Appearance Ensures consistent formatting and structure across all reports. Key Takeaways This simple yet effective approach shows that report design in Business Central can be made flexible without altering data logic.By using two tables with visibility expressions, you can create reports that adapt their appearance automatically – keeping the layout professional, stable, and easy to maintain. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com
Share Story :
Workspaces in Business Central AL Explained
When developing in Microsoft Dynamics 365 Business Central, you spend a lot of time working in Visual Studio Code. To streamline productivity and keep projects well-organized, workspaces in Business Central AL play a critical role. In this blog, we’ll explore what workspaces are, why they matter, and how you can use them effectively in your AL development journey. What is a Workspace in Business Central AL? A workspace in Visual Studio Code is essentially a container that holds your project’s structure, settings, and configurations. In Business Central AL development, a workspace defines: In short, a workspace ensures that everything needed to build and deploy an extension is neatly bundled together. Benefits of Using Workspaces Creating and Managing Workspaces Tip: Save your workspace using File > Save Workspace As… so you can reopen it quickly in future. Example: Multi-root Workspace When working with multiple extensions in a workspace, handling dependencies used to mean installing each required app one by one. Now, the development environment can automatically look at the dependency graph in your workspace and publish the necessary projects along with the one you selected. This way, you can focus on building and testing without worrying about missing dependencies. Imagine you’re working with multiple extensions in your Business Central environment: From the diagram: Base App ALProject1 ALProject2 ALProject3 Adding Folder to Workspace. Saving Workspace. Creating a separate folder to store workspaces. Publishing Full Dependency. This allows you to debug, build, and manage all the extensions from a single VS Code instance. Best Practices for Workspaces To conclude, workspaces in Business Central AL are more than just folders — they are the foundation of your development environment. By structuring your projects with well-maintained workspaces, you ensure smoother collaboration, better organization, and efficient extension deployment. If you’re just starting with AL, experiment with single-project workspaces, and as you grow, explore multi-root setups to manage larger development scenarios. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com
Share Story :
Preview and Download Selected Documents as PDFs in Business Central Using AL
In Microsoft Dynamics 365 Business Central, users frequently need to generate and review Purchase Order (PO) documents. Traditionally, this process involved downloading PDF files locally and then opening them with an external PDF viewer. While functional, this workflow can be inefficient, especially when reviewing multiple purchase orders. With recent enhancements in the AL language and web client capabilities, it is now possible to preview PDF documents directly within the browser, eliminating unnecessary steps and improving user experience. Additionally, Business Central continues to support direct file downloads for scenarios where saving a copy locally is required. This article presents a customization to the Purchase Order List page, allowing users to select multiple purchase orders and either preview or download their PDF documents using AL code. Functional Overview The proposed solution introduces a new action on the Purchase Order List page titled “Preview Selected Purchase Orders”. This action performs the following tasks: Role of Report Selections Report Selections play a vital role in ensuring flexibility and modularity. Instead of hardcoding specific report IDs, the system determines the report to be used for each Purchase Order based on vendor configuration. Example AL Snippet: This method respects configurations made in the Report Selection – Purchase page, allowing different vendors to use different report formats or layouts for the same document type. AL Implementation Below is the complete AL code for the pageextension object: File Handling Options: Preview vs Download Depending on business needs, developers can choose between two methods: 1. File.ViewFromStream 2. File.DownloadFromStream Output This customization provides two ways to handle PDF outputs for Purchase Orders: 1. For a Single Selected Document When a single purchase order is selected and the action is triggered: 2. For Multiple Selected Documents (Merged into One PDF) Business Benefits To Conclude, by leveraging AL capabilities such as Report Selections, Temp Blob, and the File data type methods, developers can significantly enhance document handling processes in Microsoft Dynamics 365 Business Central. Offering both in-browser preview and direct download options provides users with flexibility and improves overall productivity. This customization is a practical example of how small enhancements can deliver substantial value in day-to-day business operations. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com.
Share Story :
A Unified Approach to Developing Finance and Operations Applications
Microsoft’s Unified Developer Experience (UDE) helps developers build solutions that work across both Finance and Operations (F&O) and the Power Platform by providing a common, cloud-based environment. Challenges Before UDE Before UDE, developers often faced the following issues: What UDE Changes With UDE, Microsoft combines these tools into one environment, making it easier to: Why UDE Is Useful Adopting UDE brings several practical benefits for developers and organizations: Check Access, Licenses, and Capacity Before starting, make sure your user role, license, and environment capacity are all set up properly. You can check this in the Power Platform Admin Center. Starting the Setup with PowerShell To get started, open PowerShell ISE on your laptop. If you haven’t installed the required Power Platform module yet, run this command (skip it if it’s already installed): #Install the module Install-Module -Name Microsoft.PowerApps.Administration.PowerShell -Force Next, sign in to your account and prepare the JSON template that defines your environment settings. Make sure DevToolsEnabled is set to true so developer tools are available. You can also set DemoDataEnabled to true if you want sample Contoso data included by default. Write-Host “Creating a session against the Power Platform API” Add-PowerAppsAccount -Endpoint prod #To construct the json object to pass in $jsonObject= @” { “PostProvisioningPackages”: [ { “applicationUniqueName”: “msdyn_FinanceAndOperationsProvisioningAppAnchor”, “parameters”: “DevToolsEnabled=true|DemoDataEnabled=true” } ] } “@ | ConvertFrom-Json Finally, you’re ready to start the environment deployment. New-AdminPowerAppEnvironment -DisplayName “EnvironmentName” -EnvironmentSku Sandbox -Templates “D365_FinOps_Finance” -TemplateMetadata $jsonObject -LocationName “unitedstates” -ProvisionDatabase Example: New-AdminPowerAppEnvironment -DisplayName “Basic_Env” -EnvironmentSku Sandbox -LocationName “unitedstates” -Templates “D365_FinOps_Finance” -TemplateMetadata $jsonObject -ProvisionDatabase Make sure to use a proper name for your environment — it must be 20 characters or fewer. Also, pick the correct data center location based on your region (for example, I used unitedstates, but you could choose India or another available region). Alternatively: Install on an Existing Environment If you already have a Power Platform environment with a Dataverse database, you can use it to install Finance and Operations apps. Simply select the environment, navigate to Resources > Dynamics 365 apps, and then select Dynamics 365 Finance and Operations Provisioning App. Once your environment is successfully provisioned, you’ll see it listed in the Power Platform Admin Center — just like in the screenshot above. Here’s what the key information means: You’ll also see links to manage: These settings help control access and structure within your environment. This confirms your Finance + Power Platform environment is now fully functional and integrated — ready for development, testing, and customization. Make sure your user account has the System Administrator security role in Dataverse. Once assigned, this role will automatically carry over to the Finance and Operations (F&O) environment — no need to reassign it separately. If you navigate to the Dynamics 365 apps, you’ll also find pre-configured and installed solutions available. You can check out the Modules, Packages, and Operation History by simply clicking on the Environment URL. System Requirements for Setting Up the Development Environment Before you begin working with the Unified Development Experience (UDE), it’s important to make sure your machine meets the basic hardware and software requirements. Here’s what you’ll need: Workstation Requirements To ensure smooth performance while developing: Required Software The following software components are essential for working with UDE in Visual Studio: Once everything is set up, you’re ready to open Visual Studio. Make sure to run it as Administrator and choose the “Continue without code” option when prompted. This ensures all tools load properly and you’re ready to begin your development work. Install Power Platform VS Extension Go to VS > Manage Extensions > Search ‘Power Platform Tools Now, navigate to Tools > Options > Power Platform Tools and enable the specified parameters. Now, go to Tools > Connect to Dataverse Always show the full list of organizations. Avoid signing in with your current Windows user if it’s not the same account you’ve already connected to in Visual Studio. You can view the environments you previously created in PowerShell – just select the one you set up earlier. Choose the default option, unless you’re planning to create specific components for D365 CE or Power Platform—in that case, it’s best to create a dedicated solution and publisher for your work. If the X++ source code for your specific UnO DevBox version (e.g., 10.0.35) hasn’t been downloaded yet, you’ll be prompted to get it locally. After setting up the Power Platform Tools extension and connecting to your Dataverse sandbox, you’ll see an option to install the Finance and Operations extension for Visual Studio, along with the related metadata. If you didn’t get any option you can download it manually by going to “C:\Users\ShubhamPrajapati\AppData\Local\Microsoft\Dynamics365\10.0.2263.74” Meanwhile, in the background, the PackageLocalDirectory is being extracted. You can monitor the progress by going to View > Output. The installation typically takes around 30 minutes. After installation, you’ll see a few prompts the first time you open Visual Studio—just click “Yes” to continue. As you can see, all models have been downloaded successfully. You can switch between Classic View and Model View by right-clicking on the AOT. Once that’s done, navigate to Tools > Options > Power Platform Tools and apply the required changes as shown in the image below. The final step is to configure the Finance & Operations extension. In my case, I use LocalDB for the Cross Reference (Cross Ref) Database—it’s convenient because it’s already included when you install Visual Studio. If you’re using LocalDB, ensure your connection string is correct. A typical value is: (localdb)\ To set up LocalDB (if not already initialized), open Command Prompt and run: sqllocaldb create MSSQLLocalDB -s This command initializes and starts the LocalDB instance. Once LocalDB is running, your Cross Reference Database will be restored. This enables key development features such as: These features significantly enhance the development experience by improving code navigation and reference tracking. If you receive errors when trying to open certain class files (which are XML files under the hood), it’s likely because the Modeling SDK is not installed. This SDK is essential for working with … Continue reading A Unified Approach to Developing Finance and Operations Applications
Share Story :
Mastering String Functions in Business Central: Practical Examples with AL
When working with Microsoft Dynamics 365 Business Central, string manipulation is an essential part of everyday development. From reversing names to formatting messages, AL provides multiple ways to handle text. In this blog, we’ll explore different approaches to string handling through practical examples, including custom logic and built-in AL string functions. Why String Handling Matters in Business Central Strings are everywhere—customer names, item descriptions, invoice messages, and more. Being able to manipulate these strings efficiently allows developers to: Let’s dive into some real-world AL examples where we extend the Customer List page with new actions for string manipulation. Part 1: Custom String Handling Approaches 🔹 a) Method 1: Using List of Text We can reverse a string by adding each character into a List of [Text] and then calling .Reverse(). action(CFS_ReverseSelectedCustomerName) { Caption = ‘Reverse Customer Name’; ApplicationArea = All; trigger OnAction() var StringList: List of [Text]; StringLetter: Text; ReversedString: Text; begin ReversedString := ”; foreach StringLetter in Rec.Name do StringList.Add(StringLetter); StringList.Reverse(); foreach StringLetter in StringList do ReversedString += StringLetter; Message(ReversedString); end; } This approach is useful when you want more control over the collection of characters. Output: Method 2: Using Index Manipulation Here, we iterate through the string from end to start and build the reversed string. action(CFS_NewIndex) { Caption = ‘New Index’; ApplicationArea = All; trigger OnAction() var ReversedString: Text; i: Integer; begin for i := StrLen(Rec.Name) downto 1 do ReversedString += CopyStr(Rec.Name, i, 1); Message(ReversedString); end; } A more direct approach, simple and efficient for reversing text. Method 3: Using CopyStr The CopyStr function is perfect for extracting characters one by one. action(CFS_NewText) { Caption = ‘New Text’; ApplicationArea = All; trigger OnAction() var ReversedString: Text; i: Integer; begin for i := StrLen(Rec.Name) downto 1 do ReversedString += CopyStr(Rec.Name, i, 1); Message(ReversedString); end; } Part 2: Built-in AL String Functions Beyond custom logic, AL offers powerful built-in functions for working with text. Let’s explore a few. Evaluate Examples The Evaluate function converts text into other datatypes (integer, date, boolean, duration, etc.). action(CFS_EvaluateExamples) { Caption = ‘Evaluate Examples’; ApplicationArea = All; trigger OnAction() var MyInt: Integer; MyDate: Date; MyBool: Boolean; MyDuration: Duration; Value: Text; OkInt: Boolean; OkDate: Boolean; OkBool: Boolean; OkDur: Boolean; begin Value := ‘150’; OkInt := Evaluate(MyInt, Value); Value := ‘2025-09-01’; OkDate := Evaluate(MyDate, Value); Value := ‘TRUE’; OkBool := Evaluate(MyBool, Value); Value := ‘3d 5h 45m’; OkDur := Evaluate(MyDuration, Value); Message( ‘Integer = %1 (Ok: %2)\Date = %3 (Ok: %4)\Boolean = %5 (Ok: %6)\Duration = %7 (Ok: %8)’, MyInt, OkInt, MyDate, OkDate, MyBool, OkBool, MyDuration, OkDur); end; } Super handy when parsing user input or imported text data. String Functions Examples Now let’s use some of the most common string functions in AL. action(CFS_StringFunctions) { Caption = ‘String Functions’; ApplicationArea = All; trigger OnAction() var SourceTxt: Text[100]; CopyTxt: Text[50]; DelTxt: Text[50]; Len: Integer; SubstTxt: Text[100]; UpperTxt: Text[50]; LowerTxt: Text[50]; begin SourceTxt := ‘Dynamics 365 Business Central’; CopyTxt := CopyStr(SourceTxt, 1, 8); // “Dynamics” DelTxt := DelStr(SourceTxt, 1, 9); // “365 Business Central” Len := StrLen(SourceTxt); // 29 SubstTxt := StrSubstNo(‘Hello %1, welcome to %2!’, ‘User’, ‘Business Central’); UpperTxt := UpperCase(SourceTxt); // “DYNAMICS 365 BUSINESS CENTRAL” LowerTxt := LowerCase(SourceTxt); // “dynamics 365 business central” Message( ‘Original: %1\CopyStr: %2\DelStr: %3\Length: %4\Substitute: %5\Upper: %6\Lower: %7’, SourceTxt, CopyTxt, DelTxt, Len, SubstTxt, UpperTxt, LowerTxt); end; } These built-in functions save time and make string handling straightforward. To conclude, whether you’re reversing a customer’s name, converting text into other data types, or formatting user-friendly messages, AL’s string manipulation capabilities are both flexible and powerful. By combining custom logic with built-in functions, you can handle almost any text-related scenario in Business Central. Try experimenting with these functions in your own extensions—you’ll be surprised how often they come in handy! We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfronts.com.
Share Story :
Getting Started with the Event Recorder in Business Central
When developing customizations or extensions in Microsoft Dynamics 365 Business Central, working with events is a best practice. Events help ensure your code is upgrade-safe and cleanly decoupled from the standard application code. However, one common challenge developers face is figuring out which events are triggered during certain actions in the system. That’s where the Event Recorder comes in. What Is the Event Recorder? The Event Recorder is a built-in tool in Business Central that allows developers to monitor and log all published and subscribed events during a user session. Think of it as a “black box” recorder for event-driven development. It helps you identify: This tool is extremely helpful when you’re customizing functionality using event subscriptions (as per AL best practices) but aren’t sure which event to subscribe to. Why Use the Event Recorder? Traditionally, developers had to dig through AL code or documentation to find the right event to subscribe to. With the Event Recorder, this becomes faster and more efficient. Key benefits include: How to Use the Event Recorder Here’s a step-by-step guide: Step 1: Open Event Recorder Step 2: Start a New Recording Step 3: Stop Recording Step 4: Review the Results Best Practices Sample Use Case Suppose you’re trying to add custom logic every time a Sales Invoice is posted. You’re not sure which event gets triggered at that point. Using the Event Recorder: Now, you can write a subscriber in your AL code like this: [EventSubscriber(ObjectType::Page, Page::”Customer List”, ‘OnAfterGetRecordEvent’, ”, true, true)] local procedure MyProcedure() begin // Your custom logic here end; Limitations While powerful, the Event Recorder does have some limitations: To conclude, Event Recorder is an indispensable tool for any AL developer working in Business Central. It simplifies the discovery of relevant events, helps maintain clean and upgrade-safe extensions, and boosts overall development efficiency. Whether you’re new to AL or a seasoned developer, incorporating the Event Recorder into your workflow will save you time. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
Share Story :
Generate Enhanced QR Codes in Business Central Using AL and QuickChart API
QR codes have become a standard tool for sharing data quickly and efficiently—whether it’s for product labeling, document tracking, or digital payments. Now, you can generate customized QR codes and barcodes directly within Microsoft Dynamics 365 Business Central using a simple action. This feature allows users to choose the barcode type and size, embed the image into a record, and optionally download it—all with just a few clicks. It’s an easy way to enhance records with scannable information, without leaving Business Central or needing external tools. In this article, we’ll walk through how this feature works and how it can be used in real business scenarios. What This Feature Does? The “Generate Enhanced QR Code” action gives users the ability to quickly create and manage barcodes within Business Central. Here’s what it can do: Business Scenarios Where This Shines AL Code Behind the Feature Output: Choose an image size (Small, Medium, Large). Select a barcode type (QR, Swiss QR, Aztec, Data Matrix, Telepen). Store the generated image in the Picture field of the item record. To conclude, this customization shows how a simple AL code extension can greatly boost efficiency in Microsoft Dynamics 365 Business Central. By enabling quick generation and embedding of QR codes and barcodes, you eliminate manual steps and streamline processes across departments—from inventory to sales and beyond. With support for multiple barcode types, customizable sizes, and built-in download and validation prompts, this feature brings powerful functionality right into the user’s workflow—no external tools needed. Whether you’re in warehousing, retail, manufacturing, or pharma, this tool helps standardize product labeling and enhances traceability with just a few clicks. Looking ahead? You can extend this further by including additional record fields, customizing encoding logic, or supporting more document types like purchase orders or invoices. We hope you found this blog useful, and if you would like to discuss anything, you can reach out to us at transform@cloudfonts.com.
