How do I get around setfilter parameter restriction

merrilmerril Member Posts: 38
Hi Guys!

I want to set a filter on the field number in a table for certain fields. The setfilter only allows a max of 12 parameters
"Change Log Entry".SETFILTER("Field No.",'%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12|%13|%14|%15|%16',50083,5059,5056,5054,9,84,102,5061,50001,86,50002,5,6,7,91,4,50083)

Is there a method to get around this other than not using the filter, reading all the records and then using an IF statement to check for these field numbers?

Thanks in advance.

#-o

Answers

  • BeliasBelias Member Posts: 2,998
    Have you ever tried to do this?
    "Change Log Entry".SETFILTER("Field No.",'50083|5059|5056|5054|9|84|102|5061|50001|86|50002|5|6|7|91|4|50083')
    
    it's not compulsory to use parameter replacement
    :mrgreen::mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • kinekine Member Posts: 12,562
    Best will be not do it in this way and use another approach. For me it looks like wrong application design... why you need that? Isn't better to use some temporary table to insert the needed records there and work with that temporary?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • merrilmerril Member Posts: 38
    kine wrote:
    Best will be not do it in this way and use another approach. For me it looks like wrong application design... why you need that? Isn't better to use some temporary table to insert the needed records there and work with that temporary?

    I'm doing a filter on the change log for changes to the customer table. I only want to work with certain fields where changes have been made. I'm new to Nav. How would I do this using temp tables?
  • merrilmerril Member Posts: 38
    Belias wrote:
    Have you ever tried to do this?
    "Change Log Entry".SETFILTER("Field No.",'50083|5059|5056|5054|9|84|102|5061|50001|86|50002|5|6|7|91|4|50083')
    
    it's not compulsory to use parameter replacement
    :mrgreen::mrgreen:

    I will try this method Belias. thanks
  • BeliasBelias Member Posts: 2,998
    kine wrote:
    Best will be not do it in this way and use another approach. For me it looks like wrong application design... why you need that? Isn't better to use some temporary table to insert the needed records there and work with that temporary?
    why it's not good?I know it's not very nice to see and modify like I do, but if it is fixed filter, i can't see a bad reason to do that filter (maybe I'm wrong, if so, i'd like to learn why :wink: )
    thanks for any explanation
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • DenSterDenSter Member Posts: 8,305
    Belias wrote:
    why it's not good?
    Because every time that a different filter is needed, a developer has to make that modification. It's not necessarily "bad" but for most companies that means that they would have to pay an expensive hourly rate for their NAV partner to do this work.
  • BeliasBelias Member Posts: 2,998
    know it's not very nice to see and modify like I do, but if it is fixed filter
    Ok, so it's only for this reason...
    But if it's only an utility or the filter is fixed, there are no problems...this code

    "Change Log Entry".SETFILTER("Field No.",'50083|5059|5056|5054|9|84|102|5061|50001|86|50002|5|6|7|91|4|50083')

    is the same as

    "Change Log Entry".SETFILTER("Field No.",'%1|%2|%3|%4|%5|%6|%7|%8|%9|%10|%11|%12|%13|%14|%15|%16',50083,5059,5056,5054,9,84,102,5061,50001,86,50002,5,6,7,91,4,50083)

    thanks for the explanation :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • merrilmerril Member Posts: 38
    Belias wrote:
    Have you ever tried to do this?
    "Change Log Entry".SETFILTER("Field No.",'50083|5059|5056|5054|9|84|102|5061|50001|86|50002|5|6|7|91|4|50083')
    
    it's not compulsory to use parameter replacement
    :mrgreen::mrgreen:


    Thanks Belias, that worked for me
  • kinekine Member Posts: 12,562
    In this case, yes, it is ok. But without the specific information hard to say. In most cases using "magic constants" is just postponing the problem to later time. In most cases some setup table or field is good solution. E.g. "same" filter over G/L Account table will be not good solution... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.