Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Purchase order line price updating

Posted on by 53
Hi,
I created an extra field in purchase order lines called 'Web Model Number' which is an extra custom field on the 'Items' table.
It works OK generally, getting filled when I select an item.
 
I also added some code to lookup the item No. so I could just paste the web model number into the purchase order. (below)
 
 field(50110; "Web Model Code"; Code[50])
        {
            Caption = 'Web Model';
            DataClassification = ToBeClassified;
            trigger OnValidate() // This is the trigger that will be called when the field is validated and fills Web Model Code
            var
                Item: Record Item;
            begin
                if "Web Model Code" <> '' then begin
                    Item.SetRange("Web Model", "Web Model Code"); // Set the range to the value in the field
                    if Item.FindFirst()then begin
                        Validate("No.", Item."No.");
                        "Web Model Code":=Item."Web Model";
                    
                    end
                    else
                        "Web Model Code":=''; // Clear the field if no item is found
                //
                end;
            end;
        }
 
 
THE ISSUE:
If I paste the model number it correctly selects the Item 'No.' and fills the Item 'Description' but the 'Direct Unit Cost Excl VAT' field is not filled.
 
If I select an item in the normal way it correctly fills 'Direct Unit Cost Excl VAT' with the last price.
 
Any ideas?
 
 
Categories:
  • Verified answer
    CU09081641-3 Profile Picture
    CU09081641-3 53 on at
    Purchase order line price updating
    Apologies, all fixed by use of:
     
    "Direct Unit Cost":=Item."Last Direct Cost";
     
    I had assumed the whole line got refreshed when 'validating' the No. field, obviously not.
     
    My bad.
     

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans