web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Using VS C# and ValidateBeforeOriginal event to stop entering sales order.

(0) ShareShare
ReportReport
Posted on by 75,854 Moderator

I have added a customer balance summary screen to the SOP Entry screen using VS C#. On this screen is displayed a summary of the customer's current activity plus there is check box indicating if the selected customer has any past due invoices. If this box is checked I want to stop the user from entering a new order for this customer. I believe I need to use the ValidateBeforeOriginal event but how do I set this up? As a test I inserted this code but it never fires.

        void CustomerNumber_ValidateBeforeOriginal(object sender, System.ComponentModel.CancelEventArgs e)

        {
            MessageBox.Show("Hello world!");
            e.Cancel = true;
        }

I also tried this

                SopEntryForm.SopEntry.CustomerNumber.ValidateBeforeOriginal += new EventHandler(CheckPastDue);

but this won't even build.

What is the proper way to stop a user from entering an order if they have past due invoices. I need to rollback the GP events but how do I do that?

Categories:
  • Richard Wheeler Profile Picture
    75,854 Moderator on at

    I have this code firing however all it does is blank the customer name. It would preferred to have rollback all the GP events and have the cursor land on the Type/Type ID as if the user just landed on the SOP Entry screen. Is this possible?

                   SopEntryForm.SopEntry.CustomerNumber.ValidateBeforeOriginal += new System.ComponentModel.CancelEventHandler(CustomerNumber_ValidateBeforeOriginal);

           void CustomerNumber_ValidateBeforeOriginal(object sender, System.ComponentModel.CancelEventArgs e)

           {

               MessageBox.Show("Hello world!");

               SopEntryForm.SopEntry.CustomerNumber.Value = "";

               e.Cancel = true;

           }

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 366

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 360 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans