I'm going through web service code and the previous developer uses (STRSUBSTNO('
@%1', in every setfilter statement such as...
Contact.SETFILTER(Name, STRSUBSTNO('
@%1', Name));
Contact.SETFILTER(City, STRSUBSTNO('
@%1', City));
rather than
Contact.SETFILTER(Name, '%1' , Name);
Contact.SETFILTER(City, '%1' , City);
It maybe full well something I'm unaware of, but I'm looking for suggestions to why he may have used STRSUBSNO and @ in every setfilter in the navision system.
Any ideas? :-k
Comments
I'm always fighting this with setfilter too, simply because it is something you don't do each day (understatement).
Just checked a customer database where I use the same construction, so I guess it makes sense. Although there might be me more roads that lead to rome.
Contact.SETFILTER(Name, '@%1' , Name);
Contact.SETFILTER(City, '@%1' , City);
No need for STRSUBSNO ??
It might work, it might have been a workaround in a certain version. My customer comes from 3.60 and runs on 2009 now.
Have you tested both?
Contact.SETFILTER(Name, '%1' , '@' + Name);
Contact.SETFILTER(City, '%1' , '@' + City);
Contact.SETFILTER(Name, '%1' , '@' + Name);
In the following construct, any characters in Name that have a special meaning in filter construction are use in that special meaning, so, if Name = 'Procter & Gamble', the construct will filter for a Name that is 'procter' (case insensitive) AND 'Gamble' (case sensiteve)
Contact.SETFILTER(Name, STRSUBSTNO('@%1', Name));
it is equal to
Contact.SETFILTER(Name, '@'+Name));
In the following construct, the string %1, which looks like a placeholder, will not be treated as such, but as the actual value. The last Name parameter is simply ignored and the filter filters for a literal '%1' (case insensitive, if that made sense)
Contact.SETFILTER(Name, '@%1', Name);
This is how I remember what SETFILTER will do:
EDIT: I renounce the following statement. There seems to be no way to let the filter engine treat the characters @, *, ? literally.
So, to be absolutely save, you'd need to write
(End of renouncement)