Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Assign a Customer to an Item

Posted on by 47
Afternoon All, 
 
I am trying to assign a customer to an item, i have added the table extensions and page extension however how do i get this to transfer to the sales lines so that we can use this to filter the items based on customer or is there another way to do this. 
I have added the extension to the sales lines table however the boxes are there but they are not transffering from the item page to this. 
the end use for this is to have a list that is filterable by customer for the items as this is how we operate as a business as we dont sell the items we provide a service on them.
 
I have tried the below which didnt work as this was on the microsoft help but wasn't much help! 
 
tableextension 60100 CustomerParts extends Item
{
    fields
    {
        field(60100; /Customer Name/; Text[200])
        {
            Caption = 'Customer Name';
            FieldClass = FlowField;
            CalcFormula = lookup(Customer.Name where(/No./ = field(CustomerNo)));
        }
        field(60101; CustomerNo; code[20])
        {
            Caption = 'Customer No';
            TableRelation = Customer;
            trigger OnValidate()
            begin
                CalcFields(/Customer Name/);
            end;
        }
    }
    local procedure CopyFields()
    var
        dt: DataTransfer;
        dest: Record /Sales Line/;
        src: Record Item;
    begin
        dt.SetTables(Database::Item, Database::/Sales Line/);
        dt.AddFieldValue(src.FieldNo(CustomerNo), dest.FieldNo(CustomerNo));
        dt.AddSourceFilter(src.FieldNo(CustomerNo), '=%1', 'A');
        dt.CopyFields();
    end;
}
  • Sam @ Mikris Profile Picture
    Sam @ Mikris 47 on at
    Assign a Customer to an Item
    Brilliant, thank you! 
     
    Worked like a charm, all i need to do now is work out how to filter the lookup to the item to filter to the customer in the sales header and we are good to go!! 
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    Assign a Customer to an Item
    Hi, Try the following approach, so that after you select item no. in Sales Line, CustomerNo. will be displayed.
     
    Hope this helps.
    Thanks.
    ZHU
  • Sam @ Mikris Profile Picture
    Sam @ Mikris 47 on at
    Assign a Customer to an Item
    Hi, no I didn't! 
     
    I was simply trying to make it so that we when we entered new items into the inventory we could assign this to a customer so that we could filter the inventory per customer and not bring up like 100,000 or so items that we would have otherwise.
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    Assign a Customer to an Item
    Did you try to create a flowfield on Sales Line table based on the No. field of Sales Line to look at Customer No. of Item table?

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