Development Error... Language Problem

mxcmxc Member Posts: 42
edited 2003-08-20 in Navision Attain
I developed a new NAVISION report, using my native language (Portuguese). Since the boolean values in Portuguese are reflected in "Sim" and "Não" (Yes and No), in my C/AL there was something like:

SETFILTER(Open, 'Sim');

As you know, this means that I only wanted records with the field "Open" set to true.
When I later changed the NAVISION language to English and then tested the report there was the following error message:

'Sim' is not an option.
The existing options are:
No, Yes

What can I do to solve this problem? Is there a way to find the current language (I could then make an IF statement)?

Regards,
Regards,

Manuel Xavier

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this
    SETRANGE(Open, TRUE);
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • mxcmxc Member Posts: 42
    Thanks, It worked...

    Why doesn't SETFILTER accept the argument TRUE but SETRANGE does?
    Regards,

    Manuel Xavier
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Because SETFILTER has a different syntax as SETRANGE. After the field, it expects a filter expression.

    This will work also:
    SETFILTER(Open,'%1',TRUE);
    

    From the C/SIDE Online-help:
    Record.SETFILTER(Field, String, [Value],...)

    Record

    Data type: record

    The record that contains the field you want to filter.

    Field

    Data type: field

    The field you want to filter.

    String

    Data type: text or code

    The filter expression. A valid expression consists of alphanumeric characters and one or more of the following operators: <, >, *, &, |, and =. You can use replacement fields (%1, %2, and so on) to insert values at run-time.

    Value

    Data type: any

    Replacement values to insert in replacement fields in the filter expression. The data type of Value must match the type of Field.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • WaldoWaldo Member Posts: 3,412
    When using SETFILTER, you have to filter using a string, not a Value. So, the translated Value (and the translated value for a boolean is Yes or No). When using SETRANGE, you set filters using Values (not translated).

    e.g.
    SETFILTER(MyOption, MyOption::Option) will NOT work, because an option expects an integer-value, and SETFILTER wants a string. So, you have to use SETFILTER(MyOption, '%1', MyOption::Option). Mapped to your problem, when you want to use TRUE or FALSE in a SETFILTER, then you probably have to use SETFILTER(Open, '%1', TRUE);

    Off course, using SETRANGE in this case is much more appropriate ... . Just use SETFILTER when you want to apply a more complex filter on a field, like SETFILTER(MyField, '%1..%2', Number1, Number2). Filters like that are not possible with a SETRANGE.

    Hope this explenation was satisfactory ... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • WaldoWaldo Member Posts: 3,412
    Woops, we (Luc Van Dijck and me) were typing at the same time ... my appologies ...

    ... I wasn't able to erase my previous message either ...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • mxcmxc Member Posts: 42
    Luc,

    In your last reply, you wrote "From the C/SIDE Online-help:".
    What online help?

    Thanks.
    Regards,

    Manuel Xavier
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    When you are writing your C/AL code, press <F1>.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Steve_KaillSteve_Kaill Member Posts: 4
    Just for future reference there is a multilanguage document that I believe is supplied on the product cd. It explains how to use multilanguage successfully in customizations and points out some pitfalls. This document was created in the first place to help the Navision team convert the non-multilanguage product into the Attain multilanguage version. Later it was distributed to help NSCs develop in Navision multilanguage situations.

    One of the processes which uses a supplied tool finds all of the literals in the code. It puts in constants where the literals were and creates the contant definition with the literal. In this way the constant can have multiple languages associated with it whereas a literal (in single quotes) has the actual words of one language. Problem is this process changes these SetFilter literals such as 'Yes' so the next process is to manually put them back!

    Anyway, this is just to point out there are some hooks when dealing with multilanguage and the multilanguage document can help avoid them.
  • eromeineromein Member Posts: 589
    mxc wrote:
    I developed a new NAVISION report, using my native language (Portuguese). Since the boolean values in Portuguese are reflected in "Sim" and "Não" (Yes and No), in my C/AL there was something like:

    SETFILTER(Open, 'Sim');

    As you know, this means that I only wanted records with the field "Open" set to true.
    When I later changed the NAVISION language to English and then tested the report there was the following error message:

    'Sim' is not an option.
    The existing options are:
    No, Yes

    What can I do to solve this problem? Is there a way to find the current language (I could then make an IF statement)?

    Regards,

    Guys,

    Am I wrong if I'm telling you to always develop in the ENU (English) language? I think this way you will never have these kinds of problems. Or not?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • StephenGStephenG Member Posts: 99
    Hi

    Emiel you are not wrong.
    All development should be in ENU (English US) which will avoid this problem. Then you can add any languages you like to the captions and Text Constants etc...
    Answer the question and wait for the answer.
Sign In or Register to comment.