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, ...
Suggested Answer

Capturing field value change using C#

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

I have some C# code that allows the user to change the batch ID on the Sales Transaction Entry screen. I am doing this because I need to execute code behind the scenes as the batch ID is changed. The problem I have encounter is that the screen does not sense the change so as the user moves passed the batch ID field the user does not get the prompt about batch not existing, do you want to add it. Is there a way to trigger that routine so they will be prompted? If not, I will move my code to an event that senses the the batch ID being changed.

Categories:
I have the same question (0)
  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Hi Richard

    The ValidateAfterOriginal event should capture whenever the field is changed by the user.

    Is that what you are using?

    Regards

    David

  • Richard Wheeler Profile Picture
    75,848 Moderator on at

    What is the difference between ValidateAfterOriginal and LeaveAfterOriginal?

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Hi Richard

    LeaveAfterOriginal is the equivalent of a dexterity trigger after the Field Post Script.

    ValidateAfterOriginal is the equivalent of a dexterity trigger after the Field Change Script.

    The field post event happens when the focus leaves the field even if the field did not change.

    The field change event happens when the focus leaves the field AND that field has been changed OR if the change script on that field has been executed (even if the field did not have focus).

    Regards

    David

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Richard

    You should do Dexterity training, then you will understand lots more about how GP works and what VS Tools does, because VS tools is just exposing Dexterity functionality to C# and VB.Net.

    Regards

    David

  • Richard Wheeler Profile Picture
    75,848 Moderator on at

    Sounds like ValidateAfterOriginal is the better choice here as I only want my code to fire if the batch ID has been changed.

  • Richard Wheeler Profile Picture
    75,848 Moderator on at

    Are there any Dexterity training videos?

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Dexterity is best learnt with the five day training course, but as I am not coming to Summit this year, we won't be running it.

    You can also learn it will self study of the training manuals combined with some consulting time with me to make sure the concepts are bedded down.

    David

  • Richard Wheeler Profile Picture
    75,848 Moderator on at

    David, I am treating myself to my annual fishing trip next week. Perhaps during the last week of September or the beginning of October we can connect. Where do I find the the Dexterity training manuals?

  • David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    14,095 Most Valuable Professional on at

    Email me directly and we can work something out.

  • Suggested answer
    Almas Mahfooz Profile Picture
    11,009 User Group Leader on at

    Try this code, since I don't know when and from where you are trying to set batch number field, I just created this simple scenario.

     public void Initialize()
            {
    
              sopEntryWindow.CustomerNumber.ValidateAfterOriginal  = CustomerNumber_ValidateAfterOriginal;
    
            }
            
            private void CustomerNumber_ValidateAfterOriginal(object sender, EventArgs e)
            {
               
    
                if (sopEntryWindow.DocumentId.Value == "STDINV")
                {
                    sopEntryWindow.BatchNumber.Focus();
                    sopEntryWindow.BatchNumber.Clear();
                    sopEntryWindow.BatchNumber.Value = "VSTOOLS";
                    sopEntryWindow.BatchNumber.ForceValidate(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