Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Customization In standard code

Posted on by 8
public boolean validate(Object calledFrom = null)
    {
        boolean     ret;
        ret = super(calledFrom);
        if (ret && (startDate > endDate))
        {
            dflStartDate.value(dateNull());
            ret = checkFailed("@SYP4861264");
        }
        if (ret && this.isValidEndDate())
        {
            ret = checkFailed("@SYP4861266");
        }
        if (ret && (dflInvoiceDate.value() < dflEndDate.value()))
        {
            ret = checkFailed("@SYP4861265");
        }
        return ret;
    }
I want to customize the above validate method using extension class , not throwing error if (ret && (dflInvoiceDate.value() < dflEndDate.value()))
        {
            ret = checkFailed("@SYP4861265");
        }
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    Customization In standard code
    I guess you mean F&O although you're asking in the AX forum.
     
    Extensions allow you to add code before or after a method; you can't use them to change the method body itself. You either find a way how to achieve your requirements with extensions, or you must ask the author of the code (Microsoft) to make it extensible.
     
    First of all, verify that the requirement makes sense. Maybe a user ask for a meaningless thing and blindly implementing it would actually cause more problems. You gave us no context, therefore we can't evaluate that.
     
    If the requirement is valid, think about possible solutions. For example, maybe you should create an extra date field for your purpose instead of redefining the meaning of a standard one.
     
    If changing the validation is the best course of action, you should create an extensibility request to Microsoft to give you an extension point (e.g. by extracting the condition to an extensible method).
     
    In theory, you could temporarily change field values so they would meet the conditions, but even if done correctly, it can easily fail when something changes (e.g. Microsoft changes the logic). The extensibility request is a better approach.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    Customization In standard code
    Hi,
     
    You mentioned you want to use an extension class, but you posted your question in the AX forum where class extensions are not supported. Can you clarify is you are using Dynamics AX or Dynamics 365?

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

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans