Dynamics 365 Business Central – Manage Purchase Prices

In Microsoft Dynamics 365 Business Central, the purchase price is the price at which a business purchases goods or services from a vendor. The purchase price is used to track the cost of goods or services that a business acquires.
The purchase price in Microsoft Dynamics 365 Business Central is important for determining the business’s profitability and calculating the gross margin for each product or service.

The purchase price may be a fixed price agreed upon between the business and the vendor or based on market conditions or other factors. It may also vary based on the number of goods or services purchased, with larger quantities often receiving a lower purchase price.

Working with Purchase Prices

In Microsoft Dynamics 365 Business Central, the simplest way to see the purchase price of an item is on the item card. When an item is entered on a purchase document, the value in the Last Direct Cost field determines the purchase price. The Last Direct Cost specifies the item’s most recent direct unit cost. The Last Direct Cost value is updated as purchase documents for the item are posted.

If you need more complex purchase pricing you can setup Purchase Prices for Items and Vendors.

Setup Purchase Prices

  • Open the Purchase Prices page from the Item Card by selecting the Purchases Prices action from the Prices & Discounts Menu.

     

  • On the Purchase Prices page, enter the Vendor specific pricing information
    • Vendor No. Specifies the number of the Vendor to which the purchase price applies.
    • Item No. – Specifies the number of the item to which the purchase price applies.
    • Unit of Measure Code – Specifies the purchase unit of the item to which the purchase price applies.
    • Minimum Quantity – Specifies the minimum purchase quantity of the item you must buy from the Vendor to get the purchase price.
    • Direct Unit Cost – Specifies the purchase price (cost) of one unit of the selected item to which the purchase price applies.
    • Starting Date – Specifies the date from which the purchase price is valid.
    • Ending Date – Specifies the date to which the purchase price is valid.

 

You can learn more about Managing Purchase prices in Dynamics 365 Business Central here.

Note: The code and information discussed in this article are for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.

Real things I’m asked – add a field to the DropDown

  • Q: Can you add the “Search Description” to the Item DropDown?

A: Yes. In Microsoft Dynamics 365 Business Central, the DropDown fieldgroup determines the fields displayed when showing records on a dropdown page. 

Additional fields can be added to the DropDown fieldgroup using the addlast keyword in an AL Table Extension. Base table and new fields can be added to the DropDown fieldgroup.

tableextension 50100 "DVLPR Item Ext" extends Item
{
    fields
    {
        field(50100; "DVLPR New Field"; Boolean)
        {
            Caption = 'New Field';
            DataClassification = CustomerContent;
        }
    }

    fieldgroups
    {
        addlast(DropDown; "DVLPR New Field", "Search Description")
        { }
    }
}

Note: The syntax for using a DropDown must be exactly DropDown with the correct capitalization. The server will remove the duplicates if multiple extensions attempt to add the same field more than once. Fields can only be added to the field group once. Fields can only be added with addlast and fields cannot be removed through a Table Extension.

Click here to learn more about Field Groups (DropDown Controls) in Microsoft Dynamics 365 Business Central.

Note: The code and information discussed in this article are for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.

Dynamics 365 Business Central – Manage Sales Prices

In today’s price-sensitive market, a business needs flexibility when setting selling prices for products. A flexible sales price model is important for businesses because it allows them to tailor their pricing strategy to meet the needs of their customers and the market. A flexible sales price model can also help businesses be more competitive in the market. For example, if a business can offer lower prices for larger quantities of an item, it may attract more customers and increase sales. Similarly, if a business can offer customized pricing for different customer groups, it can retain customers and build loyalty.

Microsoft Dynamics 365 Business Central provides several price strategies, allowing a business to offer flexible and competitive pricing strategies. Sales Prices can be for all customers, specific customers, customer price groups, or sales campaigns. These prices may include conditions such as order date, unit of measure, or minimum quantity purchased.

Working with Sales Prices

In Microsoft Dynamics 365 Business Central, the simplest way to set an item’s sales price is on the item card. The unit price on the item card is an item’s price based on its unit of measure. The unit price is manually or calculated automatically based on the cost of the Item and the desired markup or margin by setting the Price/Profit Calculation value.

If a business requires more flexible Sales Price options, such as a price for a specific Customer or Order Date range:

  • Open the Sales Prices page from the Item Card by selecting the Sales Prices action from the Prices & Discounts Menu.
  • Enter the Sales Type for the price
    • Customer – the price is for a specific Customer
    • Customer Price Group – the price is for Customers assigned to a Price Group.
    • All Customers – the price is for All Customers.
    • Campaign – the price for a Sales Campaign
  • Sales Code – enter the value related to the Sales Type value for the Sales Price. 
    •  Sales Type of Customer – Enter the Customer No for the Customer that receives the Sales Price
    • Sales Type of Customer Price Group – Enter the Price Group for the Group that receives the Sales Price
    • Sales Type of All Customers – no value entered
    • Sales Type of Campaign – Enter the Campaign that receives the Sales Price
  • Item No. – enter the Item No. for the Sales Price 
  • Minimum Quantity – if the Sales Price is applicable for a minimum quantity ordered for the Item, enter the minimum quantity needed to receive the Sales Price.
  • Starting Date and Ending Date – If the Sales Price is effective for a specific date range, enter the starting and ending date for the date range the Sales Price is valid
  • Unit Price – the Sales Price for the Item, for the Sales Price options.

When working with Sales Prices for a Customer Price Group, a Customer is assigned to a Price Group by setting the Customer Price Group value on the Invoicing Fast Tab on the Customer Card.

When working with Sales Prices for a Campaign, Sales Documents assigned to a specific Campaign will receive a Campaign specific sales price.

Sales Prices are also accessible from the Prices action on the Prices & Discounts menu on the Customer Card. Opening the Sales Prices page from the Customer Card allows setting prices for a specific customer.

Business Central applies the best price principle. This means that the lowest price for an item is used on a sales line, but only if all conditions are met.

You can learn more about Managing Sales prices in Dynamics 365 Business Central here.

Note: The code and information discussed in this article are for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.

Dynamics 365 Business Central 2022 Wave 2 – January 2023

With each Wave update of Dynamics 365 Business Central, Microsoft publishes a list of What’s new and planned for Dynamics 365 Business Central. Not all published features are “generally available” upon the initial wave release. Some features “roll in” during the wave. Here is a listing of what is published to “wave in” January 2023.

Application

Feature Enabled for Public preview General availability
Reverse payment reconciliation journal entries Users, automatically Jan 2023 Jan 2023

Governance and administration

Feature Enabled for Public preview General availability
Get more visibility into service interruptions Users, automatically Jan 2023 Jan 2023
Get more, better communications as admin Admins, makers, marketers, or analysts, automatically Jan 2023 Jan 2023
Restore deleted environments Admins, makers, marketers, or analysts, automatically Jan 2023 Jan 2023
Restore environments to point in time Admins, makers, marketers, or analysts, automatically Jan 2023 Jan 2023
Restrict traffic on system integrations with service tags Admins, makers, marketers, or analysts, automatically Jan 2023 Jan 2023

Note: The code and information discussed in this article are for informational and demonstration purposes only. This content was created referencing Microsoft documents published at the time of this posting.

Dynamics 365 Business Central – Create a JSON File with AL

JSON (JavaScript Object Notation) is an open standard file format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values).

In today’s digital age, the exchange of data between Microsoft Dynamics 365 Business Central and other systems is often necessary. In a previous post, I covered a basic example of creating an XML file with AL. Along with XML files, I am often asked how to generate JSON files. Here is an example of creating a basic JSON file in AL.

The  example below demonstrates a basic model to provide enough information to create a simple file; consider it “Getting Started.” There are many ways to code a solution, and opinion or situation determines the best. Within Microsoft Dynamics 365 Business Central, JSON can be processed codeunit 5459 “JSON Management.” I  do use this codeunit often and may cover this example using the codeunit in the future.


    local procedure CreateJSON(Customer: Record Customer)
    var
        ShiptoAddress: Record "Ship-to Address";
        JArray: JsonArray;
        CustObject: JsonObject;
        JsonObject: JsonObject;
        ShiptoObject: JsonObject;
        JsonData: Text;

    begin
        Clear(JsonObject);
        Clear(CustObject);

        CustObject.Add('No', Customer."No.");
        CustObject.Add('Address', Customer.Address);
        CustObject.Add('Address_2', Customer."Address 2");
        CustObject.Add('City', Customer.City);
        CustObject.Add('County', Customer.County);
        CustObject.Add('Country_Region', Customer."Country/Region Code");
        CustObject.Add('Post_Code', Customer."Post Code");

        ShiptoAddress.SetRange("Customer No.", Customer."No.");
        if ShiptoAddress.FindSet() then begin
            Clear(JArray);
            repeat
                Clear(ShiptoObject);
                ShiptoObject.Add('Code', ShiptoAddress.Code);
                ShiptoObject.Add('Address', ShiptoAddress.Address);
                ShiptoObject.Add('Address_2', ShiptoAddress."Address 2");
                ShiptoObject.Add('City', ShiptoAddress.City);
                ShiptoObject.Add('County', ShiptoAddress.County);
                ShiptoObject.Add('Post_Code', ShiptoAddress."Post Code");
                JArray.Add(ShiptoObject);
            until ShiptoAddress.Next() = 0;
            CustObject.Add('Ship-to', JArray);
        end;

        JsonObject.Add('Customer', CustObject);

        JsonObject.WriteTo(JsonData);

    end;

The above code creates the JSON file displayed here:

{
    "Customer": {
        "No": "10000",
        "Address": "192 Market Square",
        "Address_2": "",
        "City": "",
        "County": "NJ",
        "Country_Region": "US",
        "Post_Code": "",
        "Ship-to": [
            {
                "Code": "LEWES ROAD",
                "Address": "2 Lewes Road",
                "Address_2": "",
                "City": "Atlanta",
                "County": "GA",
                "Post_Code": "31772"
            },
            {
                "Code": "PARK ROAD",
                "Address": "10 Park Road",
                "Address_2": "",
                "City": "Atlanta",
                "County": "GA",
                "Post_Code": "31772"
            }
        ]
    }
}

Note: The code and information discussed in this article are for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.

Dynamics 365 Business Central – Enter Customer Payments with Cash Receipt Journal

In Microsoft Dynamics 365 Business Central, customer payments can be entered using the Cash Receipt Journal. At the time of entry, customer payments can be applied to one or many open entries, or if you are not ready to apply the payments, you can apply them from the posted entries later.

To enter a customer payment via the Cash Receipt Journal:

  1. Search for Cash Receipt Journal using the “Tell Me” search feature in Microsoft Dynamics 365 Business Central
  2. Select the desired Cash Receipt Journal Batch to enter the payment Note: The journal batches may be set up for specific scenarios and may have predefined values for items such as the “Balancing Account” and  “No. Series”
  3. Fill in the values for the Payment on the Cash Receipt Journal Line.
    1. “Posting Date” is the date that you’ll register the Payment
    2. Because we are entering Customer payment, the “Document Type” would be Payment
    3. Enter the “Document No.” for the Payment if a “No. Series” is not defined for the Cash Receipt Journal Batch. The number may represent the Customer’s “Check No.” or another reference
    4. “Account Type” should be Customer, and the “Account No.” is the Customer’s number defined in Business Central.
    5. Enter the Credit Amount of the Payment
    6. Specify the “Bal. Account Type” and “Bal. Account No.” such as the number of the general ledger or bank account that the balancing entry is posted to, such as a cash account. (This may be predefined in the Cash Receipt Journal Batch)
  4. Apply the Payment to open Customer Entries
    1. If the Payment application is for one entry, you can select the “Applies-to Doc. Type” and the “Applies-to Doc. No.” of the posted document that this document or journal line will be applied to when posting.
    2. When applying a payment to one or more entries, select the “Apply Entries” action item to open the “Apply Customer Entries” page.
      1. Select the entries you would like to apply the Payment to, and select the “Set Applies-to ID” action item for each. The “Document No.” value of the journal line will populate the “Applies-to ID” field on the applied entry.
      2. If the applied Payment is not for the entire open amount, you can enter the applied amount in the “Amount to Apply” field on the open entry.
      3. Select Ok to close the “Apply Customer Entries” page.
  5. Finalize the Customer Payment by selecting the Post action item on the “Cash Receipt Journal” page

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.

It’s Friday – December 02

Don’t forget about Feature Management. It allows an administrator to enable the preview of upcoming features, allowing users access (to test) the features in a SandBox environment before they’re activated in a Production environment.

December 2022 Cumulative Updates for Dynamics 365 Business Central and Microsoft Dynamics NAV

The December updates for Microsoft Dynamics NAV and Microsoft Dynamics 365 Business Central are now available.

Before applying the updates, you should confirm that your implementation is ready for the upgrade and ensure compatibility with your modifications. Work with a Microsoft Partner to determine if you are ready and what is needed for you to apply the update.

Please note that SaaS customers will automatically be upgraded to 21.2 over the coming days/weeks and should receive an email notification when upgraded.

Direct links to the cumulative updates are listed here:

Dynamics 365 Business Central On-Premises 2022 Release Wave 2 Updates – Update 21.2 (December 2022)

Dynamics 365 Business Central On-Premises 2022 Release Wave 1 Updates – Update 20.8 (December 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 2 Updates – Update 19.14 (December 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 1 Updates – Update 18.18 (October 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 2 Updates – Update 17.17 (April 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 1 Updates – Update 16.17 (October 2021)

Dynamics 365 Business Central On-Premises 2019 Release Wave 2 Updates – Update 15.17 (April 2021)

Dynamics 365 Business Central On-Premises Spring 2019 Updates – Update 42 (December 2022)

Dynamics 365 Business Central On-Premises October’18 Updates – Update 18 (April 2020)

Microsoft Dynamics NAV 2018 – Update 59 (December 2022)

Microsoft Dynamics NAV 2017 – Update Update 61 (January 2022)

Microsoft Dynamics NAV 2016 – Update 67 (July 2021)

Dynamics 365 Business Central – Create an XML File in AL

XML (eXtensible Markup Language) is a standard for encoding documents and is used to structure data for storage and transport. XML files are just plain text files that use custom tags to describe the structure and features of the document. Many describe the file’s structure as self-descriptive and intended to be both human and machine-readable. XML files are also extensible; they don’t have a predefined Markup and allow users to create their own tags and structure.

In today’s digital age, the exchange of data between Microsoft Dynamics 365 Business Central and other systems is often necessary. Because of this, I am frequently asked how to create an XML file in AL. Here is an example of creating XML within AL.

    local procedure CreateXML(): Text
    var
        Declaration: XmlDeclaration;
        XmlDoc: XmlDocument;
        Elements: XmlElement;
        Element: XmlElement;
        ElementItem: XmlElement;
        Comment: XmlComment;
        e,
        i : Integer;
        XmlData: Text;
        XmlWriteOptions: XmlWriteOptions;

    begin
        // Create the XML Document
        XmlDoc := XmlDocument.Create();
        // Create the Declaration
        Declaration := XmlDeclaration.Create('1.0', 'utf-8', 'yes');

        // Add the declaration to the XML File
        XmlDoc.SetDeclaration(Declaration);

        // Create Root Element
        Elements := XmlElement.Create('Elements');

        // Create a comment
        Comment := XmlComment.Create('This is a comment');
        // Add comment to eleement
        Elements.Add(Comment);

        for e := 1 to 2 do begin
            Clear(Element);
            Element := XmlElement.Create('Element');

            // Set element attributes
            Element.SetAttribute('id', Format(e, 0, 9));
            Element.SetAttribute('seq', Format(Time, 0, 9));

            for i := 1 to 3 do begin
                // Create and add data elements to the element
                Clear(ElementItem);
                ElementItem := XmlElement.Create('Item' + Format(i, 0, 9));
                ElementItem.Add(XmlText.Create(Format(e + i, 0, 9)));
                Element.Add(ElementItem);
            end;
            Elements.Add(Element);
        end;

        // Add Elements to document
        XmlDoc.Add(Elements);

        // Set the option to preserve whitespace - true makes it "more human readable"
        XmlWriteOptions.PreserveWhitespace(true);
        XmlDoc.WriteTo(XmlWriteOptions, XmlData);
    end;

The resulting XML is

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Elements>
    <!--This is a comment-->
    <Element id="1" seq="08:32:08.51">
        <Item1>2</Item1>
        <Item2>3</Item2>
        <Item3>4</Item3>
    </Element>
    <Element id="2" seq="08:32:08.51">
        <Item1>3</Item1>
        <Item2>4</Item2>
        <Item3>5</Item3>
    </Element>
</Elements>

The above example demonstrates a basic model to provide enough information to create a simple file; consider it “Getting Started.” Other things may need to be considered, namespaces, for instance, in more complex exchanges. There are many ways to code a solution, and opinion or situation determines the best. Within Microsoft Dynamics 365 Business Central, XML files may also be managed with Xmlports and codeunit 6224 “XML DOM Management.”

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.

Dynamics 365 Business Central – What can you buy with Filter Tokens?

Do you use Filter Tokens in Microsoft Dynamics 365 Business Central? Have you heard of Filter Tokens?

Filter Tokens are special words that resolve to a filter string of values. Several Filter Tokens are defined in Microsoft Dynamics 365 Business Central; for example, the ‘%mycustomers’ Token (Note: when using a Filter token, an ampersand precedes the filter text) returns a filter of Customer numbers for the user’s My Customers list. The user of the ‘%mycustomers’ filter token simplifies users’ experience when filtering their customers.

You can define token words that users can enter for a filter to simplify the filtering of records. The events found in codeunit 41, “Filter Tokens,” are the key to building your own Filter Token. Subscribe to the appropriate event and compare the FilterToken entered to your word, and then make the proper TextFilter value to return from the event.

The following AL code example demonstrates creating a token, ‘USCUSTOMERS’, that constructs a filter for all customers with a Country/Region Code of ‘US’.

codeunit 50101 "DVLPR FilterToken Management"
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Filter Tokens", 'OnResolveTextFilterToken', '', true, true)]
    local procedure OnResolveTextFilterToken(TextToken: Text; var TextFilter: Text; var Handled: Boolean)
    var
        Customer: Record Customer;
        MaxCount: Integer;
    begin
        if StrLen(TextToken) < 3 then
            exit;

        if StrPos(UpperCase('USCUSTOMERS'), UpperCase(TextToken)) = 0 then
            exit;

        Handled := true;

        MaxCount := 200;
        Customer.SetRange("Country/Region Code", 'US');

        if Customer.FindSet() then begin
            MaxCount -= 1;
            TextFilter := Customer."No.";

            if Customer.Next() <> 0 then
                repeat
                    MaxCount -= 1;
                    TextFilter += '|' + Customer."No.";
                until (Customer.Next() = 0) or (MaxCount <= 0);
        end;
    end;
}

Using the Token %uscustomers for a Filter where a “Customer No.” Filter is expected, returns a filter string containing matching customers.

This example is intended only to demonstrate the use of Filter Tokens. When creating a token design, consider the design of your implementation. Complex, unreliable or time-consuming tokens may result in a less-than-desirable user experience.

Note: The code and information discussed in this article is for informational and demonstration purposes only. This content was created referencing Microsoft Dynamics 365 Business Central 2022 Wave 2 online.