Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

Customization In standard code

Posted on by 6
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 225,446 Super User 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... 285,407 Super User 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?

Helpful resources

Quick Links

First Dynamics 365 Community Call (CRM Edition)

Don't miss the first D365 Community Call on 7/10!

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 285,407 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,446 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans