Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP forum
Unanswered

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

Posted on by 75,730

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?

  • Richard Wheeler Profile Picture
    Richard Wheeler 75,730 on at
    RE: Using VS C# and ValidateBeforeOriginal event to stop entering sales order.

    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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Product updates

Dynamics 365 release plans