Filter error with Nav web service but not classic client

NavMTLNavMTL Member Posts: 9
edited 2012-01-17 in NAV Three Tier
I'm trying to call a codeunit that has the following filter

grecCustLedgEntry.SETFILTER("No.",'%1',"CLE No."+'*');

the field grecCustLedgEntry."No." has a max length of 20 characters, when the value of "CLE No." is 20 characters long the web service throws an error "The maximum length for a string value is 20.". I think that the wildcard * that I'm adding at the end of the filter is being considered in the total length. I've tested the same code from classic client and it works fine.

Has anyone come across this issue?

Comments

  • dipakpatel2505dipakpatel2505 Member Posts: 169
    Hello NavMTL,

    if you want to apply filter of more than 20 character using special character like '*','|' then donot use %1. You should create String filter first then you should apply filter directly as shown below:

    Filterstring := "CLE No."+'*';
    grecCustLedgEntry.SETFILTER("No.",Filterstring);

    If Tips is useful and solved problem then please donot forget to mark it as solved.
  • NavMTLNavMTL Member Posts: 9
    Thanks for the reply dipakpatel2505,

    I already found a way to work around the issue by doing grecCustLedgEntry.SETFILTER("No.",'%1',copystr("CLE No."+'*',1,20)); but I guess what I was looking for is if there's a hot fix for this as this issue seems to be a glitch in the Web services, as stated in my initial post the code works fine in classic client. My goal is not to have to go through all the code to try and find filters that could potentially have the same issue.
  • DenSterDenSter Member Posts: 8,307
    Actually in my opinion the bug is in the Classic Client. If the length of the field is 20, it should not accept a filter string that is longer than 20 characters.

    Taking care of string lengths in your code is always a good idea by the way.
Sign In or Register to comment.