Filtering a number of records

sabzamsabzam Member Posts: 1,149
Dear all,

I need to filter a number of records in two ways, for example:

Contact.SETFILLTER ("No.", 'X') OR Contact.Setfilter (Name, 'XX');

and the result should be where EITHER the No. is X or where the NAME is XX.

Is this possible?

Comments

  • MaximusMaximus Member Posts: 105
    This should do the trick: Contact.SETFILLTER ("No.", '%1|%2', 'X', 'XX');
  • krikikriki Member, Moderator Posts: 9,110
    @Maximus: put on your glasses :mrgreen: 1 filter is with "No.", the other with "Name".

    @sabzam:
    You can't do it in one run.
    You need to put the first filter and loop the the records, putting them in a temptable. Then you put the second filter and you loop the records and add them to the temptable.
    After that, you loop the temptable with filtering and you have all records.
    It is also possible to use MARKS, but for performance-reasons (specially on SQL) it is better to avoid MARKS.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • DaveTDaveT Member Posts: 1,039
    Hi Sabzam,


    Sorry Maximus its not that simply. You have two options here that I can think of. One is to have two record variables and filter down both. Then insert into a third temp record variable.


    The second suggestion is to add a field which combines No. and name and filter on the new field as Maximus suggests
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • sabzamsabzam Member Posts: 1,149
    Let's put it in another way. Is it possible to compare a table with a temporary table. Practically if I have got records no. 2, 3 and 7 in a temporary table, I want to have filtered these records in the actual (real) table.

    IN SQL this would be something like

    Select [No_] from [Customer] where [No_] in (Select [No_] from Vendor)
  • DaveTDaveT Member Posts: 1,039
    Hi Sabzam,

    You would to code this with MARK and select MARKEDONLY which can be slow. If your temp table is on the customer table then you can select directly from the temp. table.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
Sign In or Register to comment.