April 4, 2009 at 12:46
filed under Dynamics AX
Tagged Dynamics AX, Inheritance
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.
Creating a parameter method for this variable.
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.
KrMee
on April 6, 2009 at 16:25
Legend: “A colleague”, also known as KrMee :-)
Brett
on March 19, 2010 at 04:58
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!
Anonymous
on January 21, 2011 at 19:02
Sincerely regards!
It resolve my problem. I’s modified PurchFormLetter_Invoice
Noble_Guy
on October 18, 2011 at 02:00
Thank you very much, that’s was helpful.
Lakshmikanth
on November 4, 2011 at 06:16
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.
Awni
on December 2, 2011 at 21:06
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.
Rohit Patil
on October 22, 2012 at 16:50
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 :)
Sergio Sepúlveda M.
on October 31, 2012 at 04:15
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!
Guru
on February 10, 2016 at 13:29
Great job it solved my issue