Good morning,
I've got a question about an error that I get when trying to update some value in the PriceDiscActual form.
My goal: to set the "Discount percentage 1" value with a custom calculated value.
I thought it would be as simple as this (simplified version):
[ExtensionOf(formStr(PriceDiscActual))] final class PriceDiscActual_FV_Extension { void findPriceAgreement() { next findPriceAgreement(); this.percent1 = 0.99; } }
However, this gives me a runtime error "Invalid cast from 'System.Decimal' to 'Dynamics.AX.Application.Forms.PriceDiscActual'."
If I try to do the same logic with the salesLineDisc field it works fine as expected.
Can anyone give me some hints why the percent1 field is different from the salesLineDisc field? And how I can achieve my goal of setting the percent1 field with a custom value?
Yes I had already tried that as well. If I do that, the build already fails:
Have you tried giving like above?
like, percent1 = 0.99; without this?
Of course. When I reach the line "this.percent1 = 0.99" I get the error that I mentioned in my first post.
Have you debugged your code?
Thank you for answering Bharani Preetham Peraka . Unfortunately that doesn't really help me. As you can see in my example, I am already creating a COC extension. The extension is called correctly. My question is: why can I update the salesLineDisc field in my extension, but not the percent1 field?
To give a default value, you have to use init() or initvalue() methods at form ds and table methods. This gives a default value form is run.
If you want to override the value, then you have to write a COC or event handler when insert is happened.
André Arnaud de Cal...
292,162
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156