filters question

witcher85witcher85 Member Posts: 7
Hi!

There is a filtered "Customer" record.

I would like to get those "Sales Invoice Header" lines, where the "Sell-to Customer" field is in the Customer record.
How can I do it?

Thanks for the answer

Comments

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    e.g.
    "Sales Invoice Header".SETRANGE("Sell-to Customer No.",Customer."No.");
    "Sales Invoice Header".FINDSET;
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • witcher85witcher85 Member Posts: 7
    It's working good if I want to filter only one customer "no.", but not if i would like to filter more than one customer.
    Eg:

    filtered customer table: (No.)
    - C0001
    - C0003
    - C0008

    In the "Sales Invoice Header" these three customer have altogether 10 invoices. I would like to filter the "Sales Invoice Header" that contains these invoices only.
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    If the Customer table is already filtered then you could use
    "Sales Invoice Header".SETFILTER("Sell-to Customer No.",Customer.GETFILTER("No."));
    "Sales Invoice Header".FINDSET;
    
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • witcher85witcher85 Member Posts: 7
    it's work, but

    I have an other question:

    what there is in that case, when I filter e.g. the Sales (LCY)? This field not in the "Sales Invoice Header"...

    e.g.:
    cust.SETFILTER(cust."Sales (LCY)", '>=1000');

    "Sales Invoice Header".SETFILTER("Sell-to Customer No.",Customer.GETFILTER("Sales (LCY)")); //<-- not works
    "Sales Invoice Header".FINDSET;
  • kapamaroukapamarou Member Posts: 1,152
    Just to clear this out:

    Is this the exact code?
    You filter on cust:
    cust.SETFILTER(cust."Sales (LCY)", '>=1000');
    
    But you get the filter from customer:
    Customer.GETFILTER("Sales (LCY)")
    
  • witcher85witcher85 Member Posts: 7
    Sorry, I want to write:

    Customer.SETFILTER(Customer."Sales (LCY)", '>=1000');

    "Sales Invoice Header".SETFILTER("Sell-to Customer No.",Customer.GETFILTER("Sales (LCY)")); //<-- not works
    "Sales Invoice Header".FINDSET;
  • kapamaroukapamarou Member Posts: 1,152
    witcher85 wrote:
    Sorry, I want to write:

    Customer.SETFILTER(Customer."Sales (LCY)", '>=1000');

    "Sales Invoice Header".SETFILTER("Sell-to Customer No.",Customer.GETFILTER("Sales (LCY)")); //<-- not works
    "Sales Invoice Header".FINDSET;


    And do you filter on the Customer Code using a filter from an Amount field?
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    witcher85 wrote:
    "Sales Invoice Header".SETFILTER("Sell-to Customer No.",Customer.GETFILTER("Sales (LCY)")); //<-- not works
    Of course this doesn't work. It doesn't make no sense. "Sales (LCY)" is a decimal field and "Sell-to Customer No." is a code field related to the Customer table. If you want to see only those invoices that are addressed to Customers that have a "Sales (LCY)" greater than or equal to 1000 then you have to design your report/form in another way.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • witcher85witcher85 Member Posts: 7
    I know that it doesn't work because the different type of the field.
    That code was only a bad example.

    Have you got any hint how can i solve this problem another way?
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    It depends on what you want to do. Is it a report? How should it look like?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • witcher85witcher85 Member Posts: 7
    these code in a form button onclick function.

    I filtered the "Sales Invoice Header" then I call a codeunit function.

    These codeunit function send the invoice details for the customers via email.


    I think I can check the amount in the codeunit function. But it not a very nice solution, but if its the only then i have to do that.
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    I assume that the source table of your form is "Sales Invoice Header" and that you pass it as a record into your function.
    witcher85 wrote:
    I think I can check the amount in the codeunit function. But it not a very nice solution, but if its the only then i have to do that.
    Yes, that would be possible, but I also think that this isn't a very nice solution. What if the user wants to filter another field of the Customer table? You could pop up a Customer List where the user could filter anything and then just compare in the codeunit if the Customer in "Sell-to Customer No." is also in your list of Customers. But I think your solution shouldn't start at a Sales Invoice.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
Sign In or Register to comment.