wild cards in SETFILTER string

Same moment I found a solution for a little big problem I want you all to get avoided. I had to filter for the second part of a name field (’* surname’) and tried this according to online help ("A valid expression consists of alphanumeric characters and one or more of the following operators: <, >, , &, |, and =."): contact.SETFILTER(Name, ’ %1’, surname); I checked with CONFIRM (instead of MESSAGE) and GETFILTERS and had to realise that if there’s an asterisk (’’) in the filterstring it gets not interpreted as an operator and a replacement value but as the string itself without even replacing ‘%1’! Result = 0, obviously. Now the simple workaround: contact.SETFILTER(Name, ‘%1’, ’ ’ + surname); Why do they waste our time with such traps? Have a nice remains of the day, Tom Edited by - thoesel on 2002 Jul 11 18:09:20

Tom, Thanks for sharing your discovery. Relative to “traps”, I guess a trap is anytime the software works differently than we, based on our personal experiences and interpretation, expect it to work. Since there are often several ways of interpreting a particular syntactic construct, that means there are often several ways of misinterpreting it. Fortuntely, you appropriately decided to test your assumption before putting it into production. That means you weren’t “trapped” by your personal interpretation. Admittedly the documention could be clearer or more complete, but that is a comment I have been able to make at some point about almost every product I have ever worked with. Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner

As David says, it is just a matter of interpretation. Without actually trying, if I needed to do what you were trying, I would automatically have written:

MyTable.SETFILTER(MyField, '%1%2', '*', MyVar);

It seams obvious that anything inside the quotes should be treated as literal text, in my experience all languages work that way. Then of course we can start another thread about the symantecs of the space between the asterisk and the Variable. _________________________ David Singleton Navision Consultant since 1991 dmks22@comcast.net___________

contact.SETFILTER(Name, ‘%1’, '* ’ + surname) When using this filter. How can you do a Calcsum on the filter? I get an error message “the sum of the fields cannot be calculated due to an asterik * in the filter”

By doing it “manually”… mycalcsum := 0; IF contact.FIND(’-’)) THEN REPEAT mycalcsum += contact.fieldtosum; UNTIL (contact.NEXT = 0); Navision doesn’t allow you using the calcsum function with that kind of filters unfortunatelly… Regards,

Dont forget about Case Surname = smith contact.SETFILTER(Name, ‘%1%2%3%2’,’@’, ‘*’,surname); Would return a list with Blacksmith Smith smith Smithson I always try to use the “Search Name” for filtering no case to consider!