Wrong argument types in variable assignment

April 4, 2009 at 12:46
filed under Dynamics AX
Tagged ,

While doing some modifications to the class SalesFormLetter, I ran into something very strange. I did two simple things:

Adding an object member variable to the class declaration.

JournalId journalId;

Creating a parameter method for this variable.

Public JournalId parmJournalId(JournalId _journalId = journalId)
{
    ;
    journalId = _journalId;

    return journalId;
}

On compilation, this didn’t show any errors, but when the code was executed, the debugger popped up, and the following error was thrown upon assignment:

Wrong argument types in variable assignment

I recompiled it, ran it again, same error. A colleague took a look at my code and couldn’t find anything wrong with it either, and suggested to stop the AOS and rebuild the .aoi file, but that didn’t do it either.
When I debugged I noticed the the object member journalId didn’t sow up in the list of members in the debugger. A moment after that my colleague asked if I had tried compile forward yet, and I immediately knew that would solve the problem. It did.

MSDN states on several occasions:

It is important to compile forward from the parent class when adding a variable to a classDeclaration of a class that is inherited by other classes.

This was the case with the SalesFormLetter modifications I did.

So always remember to use compile forward when modifying super classes, and it will save you a lot of trouble.

9 comments

RSS / trackback

  1. KrMee

    Legend: “A colleague”, also known as KrMee :-)

  2. Brett

    Thanks for your blog post. I was banging my head against a wall for at least half an hour, unable to figure out why a string input couldn’t be assigned to a string variable…. – the compile forward tip worked a treat!

  3. Anonymous

    Sincerely regards!
    It resolve my problem. I’s modified PurchFormLetter_Invoice

  4. Noble_Guy

    Thank you very much, that’s was helpful.

  5. Lakshmikanth

    Hi,

    I have similar error with SalesQuotationEditLinesForm, i dont have developer license so i have created job to perform compile forward of the same.but still i am unable to resolve the error. Any help in this regards is appreciated.

  6. Awni

    Hi Lakshmikanth,

    I had exactly the same problem as yours. To sort this one out, i had to add the parameter that i defined to the parameters list in the class declaration not only in the salesFormLetter, but also in the salesFormLetter_. In addition to that, i had to compile fwd by code.

  7. Rohit Patil

    i also faced the same issue…was not able to resolve it by compile forward…i changed my license to our inhouse license..and it worked :)

  8. Sergio Sepúlveda M.

    Hi!
    I have same problem but with PurchTableForm. I’ve added a boolean variable member and a method setter and getter.

    class declaration:
    boolean xVar;

    a method:

    boolean isXVar(boolean _val = xVar)
    {
    xVar = _val;
    return xVar;
    }

    Any comment will be aprreciated!

  9. Guru

    Great job it solved my issue

respond