Open Forum

Expand all | Collapse all

Writing an AL Extension to Update Sales Lines

  • 1.  Writing an AL Extension to Update Sales Lines

    TOP CONTRIBUTOR
    Posted Feb 24, 2020 12:57 PM
    Hi All

    Written some table extensions, page extensions and reports in AL.

    I now need to write an extension that can update sales lines (several different functions), so i need to add a menu item to the Sales Line Sub Form (for sales orders and blanket sales orders). When the user selects one of the possible functions, it will iterate through all sales lines and set various values.

    I'm a bit puzzled on how to start. Have a few questions:

    Would this be a page extension?
    How would I add a menu item to the Line menu on the sub form?

    Thanks

    mark

    ------------------------------
    Mark Anderson
    Director of ERP Systems
    Clesen Wholesale
    Evanston, IL
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: Writing an AL Extension to Update Sales Lines

    TOP CONTRIBUTOR
    Posted Feb 24, 2020 06:55 PM
    There doesn't seem to be a way to delete posts, and I solved it

    In case anyone else has same problem, I created a page extension on the Sales Order Subform and used and action to add to the Line menu


    ------------------------------
    Mark Anderson
    Director of ERP Systems
    Clesen Wholesale
    Evanston, IL
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 3.  RE: Writing an AL Extension to Update Sales Lines

    GOLD CONTRIBUTOR
    Posted Mar 02, 2020 05:48 AM
    Hey Mark,

    Great Question.

    To keep it align to base Microsoft approach I would suggest this -
    1. Use Page Extensions for adding actions in the Sales order subform and Blanket Sales order Subform.
    2. Page Extension only adds the action on the page and calls a function.
    3. The Code that executes the business logic should be placed in a codeunit function which then gets triggered from both actions.

    ** Benefits of this approach.
    1. All Business Logic is supposed to be in one place (Codeunits).
    2. Pages and Tables are not supposed to be heavily coded ever.
    3. Easy to Manage in future, as you will only have to update the Function once in a codeunit and it will apply changes to both actions.
    4. It aligns with Microsoft Best Practice for Development either in C/AL or AL.

    I hope it helps.

    ------------------------------
    Saurav Dhyani
    Upgrade Technical Futurist
    ArcherPoint Inc.
    Duluth
    Blog - https://saurav-nav.blogspot.com
    ------------------------------

    Academy - Online Interactive Learning from Experts


  • 4.  RE: Writing an AL Extension to Update Sales Lines

    TOP CONTRIBUTOR
    Posted Mar 02, 2020 01:17 PM
    Thanks for the tips.

    That is how I structured it

    ------------------------------
    Mark Anderson
    Director of ERP Systems
    Clesen Wholesale
    Evanston, IL
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role