How to set a language-neutral filter ?

navvynavvy Member Posts: 79
Hi,

I'm trying to find all records in the table 5054 "Contact Business Relation" with "Customer" on the field "Link to Table". The "Data Type" of this field is "Option": filter.jpg

When I set a filter like....
ContactBusinessRelation.SETFILTER("Link to Table", 'Customer');
.... it works fine if the language in NAV is set to English. If the language in the NAV Client is set to another language, it's not working ](*,)

Is it possible to set set a language-neutral filter ?
navvy
Freelance Developer

Answers

  • girish.joshigirish.joshi Member Posts: 407
    Yes, it is possible.

    You should write your code like this:
    ContBusRelation.setfilter("Link To Table",'%1',ContBusRelation."Link To Table"::"Customer");
    

    The way you have written the code, you are trying to do an implicit conversion between a type of string to a type of option. The way the implicit conversion is handled varies depending on your language setting.

    If you use the NAV representation of the value you don't have a problem.
  • navvynavvy Member Posts: 79
    It works, cool, thank you :D

    But how does it works ? #-o The implicit conversion is clear, but what's the meaning of :: between "Link to Table"::Customer ?
    navvy
    Freelance Developer
  • tinoruijstinoruijs Member Posts: 1,226
    edited 2008-02-19
    :: is used for option-fields.
    Another example:
    Status is an option-field with 2 options Open and Released.
    IF Status = Status::Released THEN...

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • girish.joshigirish.joshi Member Posts: 407
    Could you put [Solved] in the title?
  • navvynavvy Member Posts: 79
    ok, that's clear. Last question: If I use the :: for option-fields, in which language must the option-value (for example: "Released" or "Customer") be defined ?
    navvy
    Freelance Developer
  • girish.joshigirish.joshi Member Posts: 407
    As long as the optionstring ML property has been set, you can define the option string for many different languages.

    Than whatever language you have set the application in will compile if have the right optionstring for that language entered in C/AL.

    However, when you look at the code the next time you open it, I believe your code will be in the default Language.
  • navvynavvy Member Posts: 79
    girish.joshi, thanks for the explanation, now I understand how it works. 8)
    navvy
    Freelance Developer
  • kinekine Member Posts: 12,562
    As long as the optionstring ML property has been set, you can define the option string for many different languages.

    Than whatever language you have set the application in will compile if have the right optionstring for that language entered in C/AL.

    However, when you look at the code the next time you open it, I believe your code will be in the default Language.

    What you are entering in the code is what is in the "OptionString" which is not language depending. Just the captions, which are used in the user interface depends on the language.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • navvynavvy Member Posts: 79
    But an OptionStringML (Multilanguage) exist ?
    navvy
    Freelance Developer
Sign In or Register to comment.