Skip to main content

Notifications

Announcements

No record found.

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

All customer should be available in customer list which are assign also in customization

Posted on by 15

I have did an customization in customer card with 2 fields, Primary person code and secondary person code which code is coming from user setup table salesperson/purchaser field in that i want for the userId which salesperson code is assign only those customer should be visible in customer list  whenever customer list opens.

i am working with this code but it is only those customer are visible which are assign to salesperson code not the primary and secoandry so what should i do for that?

- by extending customerlist

trigger OnAfterGetRecord()
    begin
        Vuser.SetFilter("User ID", UserId);

        if Vuser.FindFirst() then begin
            if Vuser."Salespers./Purch. Code" <> '' then
                Rec.SetFilter("Salesperson Code", Vuser."Salespers./Purch. Code");
    end;
 VSalesperson: Code[20];
        Vuser: Record "User Setup";
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: All customer should be available in customer list which are assign also in customization

    Hi, just add others's reply, Have you tried the Security Filters feature, this doesn't require customization.

    pastedimage1651793314522v1.png

    More details: https://docs.microsoft.com/en-us/dynamics-nav/how-to--set-security-filters

    And an example in BC:

    https://yzhums.com/10133/

    Hope this also helps.

    Thanks.

    ZHU

  • Suggested answer
    Dallefeld Profile Picture
    Dallefeld 11,425 User Group Leader on at
    RE: All customer should be available in customer list which are assign also in customization

    Have you looked at using Responsibility Center? This standard feature will filter various lists based on the User Setup Responsibility center.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: All customer should be available in customer list which are assign also in customization

    Hi,

    Only field's value to be filtered one at a time, if you want to put the filters based on the priority, in that you have to write a case like if you are aware about the Sales price list, which works based on the Customer, Customer Price group etc. priority.

    for now please try below code.

    {

      trigger OnOpenPage()

      begin

          rec.FilterGroup(2);

          Vuser.get(UserId);

          if Vuser."Salespers./Purch. Code" <> '' then begin

              Rec.SetRange("Salesperson Code", Vuser."Salespers./Purch. Code");

              //Rec.SetRange("Secondary Salesperson No.", Vuser."Salespers./Purch. Code");

              rec.FilterGroup(0);

          end;

      end;

      var

          VSalesperson: Code[20];

          Vuser: Record "User Setup";

    }

    Thanks

  • PoojaZinjurke Profile Picture
    PoojaZinjurke 15 on at
    RE: All customer should be available in customer list which are assign also in customization

    salesperson Code and Secondary salesperson no have the table relation from usersetup table with Salespers./Purch. Code field

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: All customer should be available in customer list which are assign also in customization

    Ok, so my question, which field in the customer card has a same value as User setup does?

    Also please try to comment out one of the setrange which don't have same values as user setup Sales pers/purch. code does.

    Then please try again.

    Thanks.

  • PoojaZinjurke Profile Picture
    PoojaZinjurke 15 on at
    RE: All customer should be available in customer list which are assign also in customization

    here is my code by extending Customer list

    pageextension 50100 CustomerListExt extends "Customer List"

    {

       trigger OnOpenPage()

       begin

           rec.FilterGroup(2);

           Vuser.get(UserId);

           // Vuser.SetFilter("User ID", UserId);

           //if Vuser.FindFirst() then begin

           if Vuser."Salespers./Purch. Code" <> '' then begin

               Rec.SetRange("Salesperson Code", Vuser."Salespers./Purch. Code");

               Rec.SetRange("Secondary Salesperson No.", Vuser."Salespers./Purch. Code");

               rec.FilterGroup(0)

               //Rec.SetFilter("Secondary Salesperson No.", Vuser."Salespers./Purch. Code");

           end;

       end;

       var

           VSalesperson: Code[20];

           Vuser: Record "User Setup";

    }

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: All customer should be available in customer list which are assign also in customization

    please share your code. Also please let me know which page you used.

    Thanks.

  • PoojaZinjurke Profile Picture
    PoojaZinjurke 15 on at
    RE: All customer should be available in customer list which are assign also in customization

    Thanks NItin Verma for your answer i tried the same as you suggested but its not working.

    Thanks

  • Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: All customer should be available in customer list which are assign also in customization

    Hi PoojaZinjurke,

    Please use below code on Customer List's Page on OnPage Trigger.

    OnOpenPage()

    FILTERGROUP(2);

    UserSetup.GET(USERID);

    IF UserSetup."Salespers./Purch. Code" <> '' THEN

     SETRANGE("Salesperson Code",UserSetup."Salespers./Purch. Code");

    FILTERGROUP(0);

    You can put setrange with your customer's custom field

    Thanks.

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