Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Want to through an error message on click of the Manu Item button on a SalesTable Form if Sales Lines are not present for SalesId as soon as the button is clicked.

Posted on by 502

4064.SalesOrder.pngHello all,

Want to through an error message on click of the Manu Item button on a SalesTable Form if Sales Lines are not present for SalesId as soon as the button is clicked.

Where I can write code to do the above requirement and what code should I write to do that.

The screenshot is attached where the button is marked with red color.

Thank You

Siddhant

*This post is locked for comments

  • Suggested answer
    Khushhal Garg Profile Picture
    Khushhal Garg 1,514 on at
    RE: Want to through an error message on click of the Manu Item button on a SalesTable Form if Sales Lines are not present for SalesId as soon as the button is clicked.

    What is the object behind 'Import csv' menu item. If it is a button on form and not a menu item then write logic on Clicked method of this button. Otherwise, it is better to write it on object behind 'Import csv' menu item button based on caller or record in args object.

    Just select firstonly salesline where salesline.salesid = salestable.salesid and if it return no record then throw error.

    If you are passing SalesLine as datasource to menu item button then on object behind button can check if element.args().record is NULL then error can be thrown.

    So there are quite a few options to achieve this requirement.

  • Verified answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Want to through an error message on click of the Manu Item button on a SalesTable Form if Sales Lines are not present for SalesId as soon as the button is clicked.

    Hi!

    You should use the clicked() method on that button.

    Put your code before calling the super().

    The code should be something like this:

    void clicked()
    {
        SalesLine   salesLineToCheck;
        
        select firstOnly salesLineToCheck
            where salesLineToCheck.SalesId == SalesTable.SalesId;
        
        if (salesLineToCheck)
            super();
        else
            throw error("Your error text");
    }

    But, the best way is to create the method on the SalesTable and then call them in your clicked() method.

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans