Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How do I add a custom ...
Finance forum
Unanswered

How do I add a custom Best Practice rule to look for an attribute?

Posted on by
Dear All
 
I wanted to add a new BP Rule that warns users whenever their methods in an object/class lacks the [Replaceable] attribute so that methods are extensible for others to be used. I couldn't find any examples online for this matter. Could anyone please give me a guideline on how to make this work?
 
Thanks
  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    How do I add a custom Best Practice rule to look for an attribute?
    First of all, your question seems to be about F&O, therefore I've moved it from D365 general forum.
     
    My understanding that you need to utilize BestPracticeMetadataChecker, list methods of a Microsoft.Dynamics.AX.Metadata.MetaModel.AxClass and check its attributes. I don't remember properties that these classes have, but I think that AxClass has Methods property (giving your an array of objects representing methods) and that the method class has something like an Attributes property.
     
    Classes can't be decorated with Replaceble attribute. And most methods shouldn't be either, because you normally don't want your logic to be ignored. That could often lead to very bad things, such as inconsistent database.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held 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... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans