Options

wrong expression

ara3nara3n Member Posts: 9,256
I've run into this problem a couple of times. The CU is compiled and is running on live system.

when you design it, you see that
wrong expression

is written in Codeunit in certain area and would not compile.



I would have to find out what the actual code is and compile it again.

It mostly happens when a function is called.
Ahmed Rashed Amini
Independent Consultant/Developer


blog: https://dynamicsuser.net/nav/b/ara3n

Comments

  • Options
    MBergerMBerger Member Posts: 413
    If had this too once...
    It happens when you change fieldnames ( making them longer ) used in the CU AFTER this CU has been compiled. It is then possible that when NAV decompiles the CU to show it on screen, the line doesn't fit anymore ( there is a maximum line length ) , and you get the "wrong expression" thing.

    Example :
    let's say ( just for the example ) that the maximum line length is 30 characters.
    if you have this line :
    setrange("Order no.",Orderno);
    
    if you then change the fieldname in the original table to "Purchase Order No.", and you open the CU, the error will occur, because the line length has gone over the 30 characters !
  • Options
    ara3nara3n Member Posts: 9,256
    That makes sense.

    Thanks.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    sylvainroysylvainroy Member Posts: 12
    I know this topic is a bit old, but I just ran into this "wrong expression" in a NAV 2009 CodeUnit and I cannot find a way to recover from that...

    I exported the code unit in text and it presents the same thing as in the C/AL editor, thought I could do something by exporting in .fob and reimporting into a plain Cronus database but it does the same as well.

    Any idea what can be done?
  • Options
    ara3nara3n Member Posts: 9,256
    It could be any line where it's more than certain length. You need to find the longest line and see if you had increased the name of the field or variable. Once you find it the line split in half
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    sylvainroysylvainroy Member Posts: 12
    Thanks for the very quick reply Rashed and I understand what you mean, but take a look at the snapshot below:


    My understanding is that there is some code "behind" the Wrong Expression line... Am I right? And if so, is there a way to recover it?

    Thanks again.
  • Options
    ara3nara3n Member Posts: 9,256
    If you have enabled Service tier boolean checked in file->Company->alter, you can look at c# code. That's the only thing I can think of.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    geordiegeordie Member Posts: 655
    sylvainroy wrote:
    My understanding is that there is some code "behind" the Wrong Expression line... Am I right? And if so, is there a way to recover it?

    Thanks again.

    I encountered this behavior making a manual .txt merge and importing the object with a line longer than 132 characters: in that case hopefully I kept the original source objects and manually modified the line.

    Do you have a previous codeunit version to check?
Sign In or Register to comment.