Skip to main content

Notifications

Announcements

No record found.

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.
  • VV-19021046-0 Profile Picture
    12 on at
    Dynamic Pricing: PO Price + Markup Automatically Updating Linked SO in D365
    @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.
  • Verified answer
    Holly Huffman Profile Picture
    3,298 on at
    Dynamic Pricing: PO Price + Markup Automatically Updating Linked SO in D365

    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();
            }
        }
    }

     

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

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,880 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans