Options

SetView Problem in Greek Language

johndimjohndim Member Posts: 17
I have a Record Variable "jdRecServiceItems" and when i press a button on the Customer Form
i have the following code :
jdRecServiceItems.SETVIEW('SORTING(Customer No.,Ship-to Code,Item No.,Serial No.) WHERE (Customer No. = FILTER(' + "No." + '))');
It works fine when i use the English Language , but when i choose to Change the Language to Greek from the menu Tools\Language when i press
the button i take the following error message :
"A ')' is missing from TableView Sorting(Customer No.,Ship-to Code,Item No.) WHERE (Customer No. = FILTER(Cust0003))"

As i said it works fine when Navision runs with English Language with no errors

Cust0003 is the value of the field "No." in the customer table.

Any ideas ? :?

Comments

  • Options
    kinekine Member Posts: 12,562
    try using '<' and '>' at the beginning and end (as in CALCDATE). I don't use the SETVIEW. It is only idea... :?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    pdjpdj Member Posts: 643
    I think the problem is that "Customer No." doesn't exist in Greek.
    If you look at the output from rec.getview, you will notice that it is language dependent, since it is using field captions and not field names. To make it language independent you should use field numbers.

    I'll recommend that you try making a dummy codeunit and set the filters you wish and then call rec.getview(false). Then use this format instead, it is language independent.
    Regards
    Peter
  • Options
    fbfb Member Posts: 246
    Pardon my (perhaps foolish) question, but why use SETVIEW?

    Why not use SETCURRENTKEY along with SETRANGE/SETFILTER?
  • Options
    ArhontisArhontis Member Posts: 667
    Hello,

    It is really strange, and the error can be reproduced.

    Have you posted it to the partnersource as a support request to get MBS opinion?
  • Options
    ArhontisArhontis Member Posts: 667
    Hi,

    I posted an incident to MBS and the responce was:
    11/29/2004 1:15:00 AM PST -- Stefan Rißling Hallo Arhontis,
    this is the news from the escalation level:

    I reproduced it on the Danish version. The reason is fieldcaptions. This line works in ENU:
    SI.SETVIEW('SORTING("Customer No.")');
    
    But not in Danish, Gernam or Greek. In Danish, it would have to be:
    SI.SETVIEW('SORTING("DebitorNr.")');
    

    You can do one of two thins to make it work in any language. Either use field captions, or change the language temporarily:

    1) Use Field Captions:
    Replace
    SI.SETVIEW('SORTING("Customer No.")');
    
    with
    SI.SETVIEW(STRSUBSTNO('SORTING("%1")',SI.fieldcaption("Customer No.")));
    

    2) Change language temporarily:
    OrgLanguage := GLOBALLANGUAGE; // Keep the original language
    GLOBALLANGUAGE&#40;1033&#41;; // change language to US English
    SI.SETVIEW('SORTING("Customer No.")');
    GLOBALLANGUAGE&#40;orglanguage&#41;;// Change the language back
    

    I would probably use fieldcaptions, but both methods will work.
  • Options
    ajhvdbajhvdb Member Posts: 672
    Did anyone tried the advice given by pdj. I think it should work.
  • Options
    ArhontisArhontis Member Posts: 667
    More on the issue from MBS escalation team:
    I said:

    Thanks for your responce, I think that it should work in any language, since it works in ENU, is it going to be fixed in the future?

    And what is the difference between the:
    SI.SETVIEW('SORTING("Customer No.")');
    and
    SI.SETVIEW('SORTING("DebitorNr.")');
    that raises a parenthesis error?
    11/30/2004 4:43:00 AM PST -- Stefan Rißling
    Hallo Arhontis,

    here is some more information from our escalation colleagues:

    Since we enabled multilanguage, it has been bad practise to use hardcoded field names in C/AL Code, and you have to use FIELDCAPTION in many places if you want yuor solution to work in multilanguage. Maybe this makes developing a little more time consuming, but this is by design. Large parts of the standard application had to be redeveoped to use Captions.

    Because SETVIEW is a string, it just tries to apply the string as a filter. The SETWIEW command does not validate whether the filter is valid or not. Maybe the error message about the ')' is misleading, but it is down to the developer to make sure that the SETVIEW parameter is correct. If you run in ENU, then
    SI.SETVIEW('SORTING("DebitorNr.")');
    would be the same to Navision as
    SI.SETVIEW('SORTING("xxyyzz9932nwdoeidfnwef#ef#wf3")');

    And you can imagine that the error message could be anything.

    Chapter 18 in the Application Designers Guide (1w1adg.pdf on the product CD) describes a bit more about how to handle multilanguage in C/AL.
  • Options
    pdjpdj Member Posts: 643
    ajhvdb wrote:
    Did anyone tried the advice given by pdj. I think it should work.
    Apparently not :roll: (Is there an offended smile anywhere?)

    It is even documented in the on-line help:
    ...The value of the String parameter can be one returned by GETVIEW.
    and
    If it is set to TRUE (default value) or if it is empty, the returned string contains references to field captions in the table that the record is associated with. If the parameter is set to FALSE, field numbers are used instead.
    PS: Please don't consider it a bug. CRM is using this to show Saved Criteria filters using the current user's language. It does it by storing the views using fieldnumbers and then on the form convert to fieldcaptions. Pretty neat if you ask me ;-)
    Regards
    Peter
  • Options
    ArhontisArhontis Member Posts: 667
    pdj wrote:
    I'll recommend that you try making a dummy codeunit and set the filters you wish and then call rec.getview(false). Then use this format instead, it is language independent.
    Your recommendation about the codeunit is interesting.

    If I understand correctly you suggest to create codeunit with a function that returns the GETVIEW(false) string of a given record. Right?

    Must I create a function for every table I need convertion of the string? Cause the SETVIEW or SETFILTER is table specific.

    I am not sure I get it... Could you be a little more specific?
  • Options
    pdjpdj Member Posts: 643
    No, that was not what I meant :-)
    I just wanted you to make a simple codeunit like this:
    OnRun()
    GLEntry.SETCURRENTKEY("Document No.","Posting Date");
    MESSAGE('Getview(true)=%1\Getview(false)=%2',GLEntry.GETVIEW(TRUE),GLEntry.GETVIEW(FALSE))
    
    Then you would notice that the output is like this:
    Getview(true)=SORTING(Document No.,Posting Date)
    Getview(false)=SORTING(Field6,Field4)
    
    And when I run it using Danish settings:
    Getview(true)=SORTING(Bilagsnr.,Bogføringsdato)
    Getview(false)=SORTING(Field6,Field4)
    
    "My" method works every time. It depends how you are to use it if you can use the method described by Arhontis.
    // Arhontis
    (SI.SETVIEW(STRSUBSTNO('SORTING("%1")',SI.fieldcaption("Customer No.")));
    
    If you store this string in a database it will fail later if a user is using a different language. So I will recommend that you the fieldnumbers instead of fieldcaptions unless you wish to show it to the user. Anything that is stored anywhere should be language independent. So back to the question from fb
    fb wrote:
    Pardon my (perhaps foolish) question, but why use SETVIEW?
    Why not use SETCURRENTKEY along with SETRANGE/SETFILTER?
    which you haven't answered yet... :-)

    Later edition: SORRY!!! I thought the last post was from johndim and not from Arhontis. My mistake :-(
    Regards
    Peter
  • Options
    ArhontisArhontis Member Posts: 667
    Hello,

    Thanks for the explanation, I have done this experiment and GETVIEW(FALSE) is a nice workarount...

    Personaly I always use SETCURRENTKEY and SETRANGE/FILTER and haven't got any problems yet...

    If I am to use SETVIEW in the future I would build a func of my own, change the language temporarily, do a SETVIEW, get the GETVIEW(FALSE), change the lang back and do the SETVIEW with field numbers...

    Nice trick pdj! :)
  • Options
    johndimjohndim Member Posts: 17
    I want to thank everybody for the participation
    i tried Arxontis solution and it worked
    when i find some time i'll see the rest recomendations as well
    Thank you all again =D>
Sign In or Register to comment.