web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

Dynamic Pricing: PO Price + Markup Automatically Updating Linked SO in D365

(4) ShareShare
ReportReport
Posted on by 12

We use service items (e.g., subcontracting) in Microsoft Dynamics 365 Finance & Operations (D365 F&O). When a service item is added to a Sales Order (SO), a related Purchase Order (PO) is created simultaneously.

Requirement:

  • The sales order line (service item) should automatically update its price as (PO Purchase Price + Markup) once the PO price is entered and confirmed.
  • The price update should only apply to the linked SO line that is connected to that specific PO.
  • Other Sales Orders containing the same service item should not be affected.
I have the same question (0)
  • Verified answer
    Holly Huffman Profile Picture
    6,544 Super User 2025 Season 2 on at

    To achieve dynamic pricing in Microsoft Dynamics 365 Finance & Operations (D365 F&O) where the Sales Order (SO) line price is automatically updated based on the Purchase Order (PO) price plus a markup, you can follow these steps:

    Step-by-Step Solution

    1. Create a Custom Field for Markup:

      • Add a custom field to the service item to store the markup percentage or amount.

    2. Develop a Custom Workflow or Extension:

      • Create a custom workflow or extension to handle the price update logic. This will involve writing code to update the SO line price based on the PO price plus the markup.

    3. Event Handler for PO Confirmation:

      • Implement an event handler that triggers when the PO is confirmed. This event handler will execute the custom logic to update the linked SO line price.

    4. Update SO Line Price:

      • Write the logic to update the SO line price. This logic should:

        • Retrieve the PO price.

        • Calculate the new SO line price as PO Price + Markup.

        • Update the SO line price only for the linked SO line.

    Example Code Snippet

    Here's an example of how you might implement the event handler and price update logic in X++:

     

    [EventHandler(eventType = FormDataSourceEventType::ValidatedField, formDataSource = tableStr(PurchTable), field = fieldStr(PurchTable, Confirmed))]
    public static void PurchTable_OnConfirmedFieldValidated(FormDataSource sender, FormDataSourceEventArgs e)
    {
        PurchTable purchTable = sender.cursor();
        PurchLine purchLine;
        SalesLine salesLine;
        SalesTable salesTable;
        MarkupPercentage markup;
        // Loop through all PO lines
        while select purchLine
            where purchLine.PurchId == purchTable.PurchId
        {
            // Find the linked SO line
            select firstOnly salesLine
                where salesLine.PurchId == purchLine.PurchId
                   && salesLine.ItemId == purchLine.ItemId;
            if (salesLine)
            {
                // Retrieve the markup percentage
                markup = salesLine.MarkupPercentage;
                // Calculate the new SO line price
                salesLine.SalesPrice = purchLine.PurchPrice + (purchLine.PurchPrice * markup / 100);
                // Update the SO line
                salesLine.doUpdate();
            }
        }
    }

     
  • VV-19021046-0 Profile Picture
    12 on at
    @Holly Huffman Hey Holly, thank you for the response. This custom approach mentioned below is definitely possible. We already have something similar developed for our system. However I am exploring standard approach without cusotmization.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 258 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 164 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 46

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans