Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to know either to use classes or table level changes

Posted on by 2,988

Hi Experts,

I have a confusion some time we want to make customization(bring changes) to any form. So what will be our first choice, Classes or tables.I mean to say the customization should be done by AOT classes or tables?. 

Best Regards,

Shabir Ahmad

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: How to know either to use classes or table level changes

    Hi Shabir,

    actually before writing any code anywhere, please check if you could rather use the standard functionality to solve your business requirement. You should consider using "Invoice and delivery on hold" field in Customer form - Credit and Collections FastTab.

  • Shabir Ahmad Profile Picture
    Shabir Ahmad 2,988 on at
    RE: How to know either to use classes or table level changes

    Hi Jay Barot,

    I got the view of Martin, i am cleared what he said the purpose of my post was to Clear 2 things 1 is how to get the requirement on customer  master form, which martin cleared me and the 2 point was if we are using table level methods then where we will use these classes attached with all modules and its functionalities Matin said to use Class SalesTableType how i will know that other sales and customers related classes will be used. Hope so you will get my point.

    Best Regards,

    Shabir Ahmad

  • Suggested answer
    Jay Barot Profile Picture
    Jay Barot 1,500 on at
    RE: How to know either to use classes or table level changes

    Hi Shabir,

    I agree with martin's first comment. You can use both classes and table but you have to decide that what exactly you want to write and where. It depends on case to case basis so no permanent answer that either use table or class.

    If it is a very small code or limited to that particular form or table then better to write code in table method and if you want to reuse the same code or function better to create class and wherever required you can declare the class object and call the method.

  • Shabir Ahmad Profile Picture
    Shabir Ahmad 2,988 on at
    RE: How to know either to use classes or table level changes

    Thanks Martin,

    That's what i was looking for, and i was saying where to use table level logic and where to use Classes level. Further, Yesterday, i made a post here Usage of classes because of this so my this point is clear here dear.

    Best Regards,

    Shabir Ahmad

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: How to know either to use classes or table level changes

    If you want to throw an error when changing a value of of table field, you don't have many options. You need to use validateField() method on the table. Of course, you can call a class from this table method, if you have a reason to do it. And that's what happened in this case - validateField() (indirectly) calls validateField() method of SalesTableType class.

    Also, you should still put the validation on saving as well (validateWrite()), because validateField() typically isn't called if data is change in another way thay through GUI.

  • Shabir Ahmad Profile Picture
    Shabir Ahmad 2,988 on at
    RE: How to know either to use classes or table level changes

    Thanks once again for your response,

    As i said before, as we checked on that customer and while we are going to make SO and in SO we select that customer account then the system  throw an error. Let say i checked the check-box on customer ABC then go to Sales order and in sales order creation time sales order ask for customer account as i select Customer ABC account the system throw an error"You can not create a sales order for this customer due to this reason etc"

    Best Regards,

    Shabir Ahmad

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: How to know either to use classes or table level changes

    You need to think more about the logic that you want before you can start deciding implementation details.

    You said that an error should be thrown, but when? When you're selecting a customer for a new order? When you're trying to save an order with such an customer? When confirming the order? Or somewhere else?

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: How to know either to use classes or table level changes

    If you only want to prevent orders from being created on the salesTable form but do not want to touch other existing structures, you can write on the form. If this control will work in all cases, you should write it to the table.

    You also need to consider the status of SalesTableListPage. As you know, code is not written to listPages.

  • Shabir Ahmad Profile Picture
    Shabir Ahmad 2,988 on at
    RE: How to know either to use classes or table level changes

    Hi Martin,

    I want to add a check on the customer master as we checked that check-box , user will not be able to make sales order for that customer and it will throw an error accordingly. This check-box will be checked by us.As it is checked it will generate that kind of error.

    Best Regards,

    Shabir Ahmad

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: How to know either to use classes or table level changes

    There is no single answer - some logic belongs to forms (UI logic), some to tables and some to classes. Often you have more than one option - e.g. you could put a simple logic into a table, but you'll rather create a class when it becomes more complicated.

    If you want a more specific answer for your scenario, please tell us what kind of changes you have in mind.

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