Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How to know either to use classes or table level changes

Posted on by 3,024

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,156 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 3,024 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,502 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 3,024 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 230,214 Most Valuable Professional 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 3,024 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 230,214 Most Valuable Professional 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 2024 Season 1 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 3,024 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 230,214 Most Valuable Professional 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.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans