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

Notifications

Announcements

No record found.

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,848 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:
I have the same question (0)
  • Richard Wheeler Profile Picture
    75,848 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans