web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Error on updating field in PriceDiscActual form extension

(0) ShareShare
ReportReport
Posted on by 133

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?

I have the same question (0)
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    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.

  • FV@E Profile Picture
    133 on at

    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?

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Have you debugged your code?

  • FV@E Profile Picture
    133 on at

    Of course. When I reach the line "this.percent1 = 0.99" I get the error that I mentioned in my first post.

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    pastedimage1683632337795v1.png

    Have you tried giving like above?

    like, percent1 = 0.99; without this?

  • FV@E Profile Picture
    133 on at

    Yes I had already tried that as well. If I do that, the build already fails:

    pastedimage1683632995656v1.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 791 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 333 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans