Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

GP2010 VS Tools - PostButton event handlers does not work.

Posted on by 105

Hi everyone, I need your help.

I transferred code for the plug-in developed using Visual Studio tools for GP10 to GP2010 and almost all code works fine, but I have a problem with handling PostButton click events on RmCashReceipts form (Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickBeforeOriginal and Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickAfterOriginal).

It looks like API does not fire this events. It’s very strange, because other handlers for this form work fine (Save button click events, Open form events, etc.). I also tried to hide PostButton (Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.Hide()) and PostButton on CashReceipts form disappeared.

I downloaded and tried Visual Studio tools for GP2010, but got the same results - nothing in errors output, but PostButton events handlers do not work.

Here is my code:

Code:
public void Initialize()
           {
               //Post button handlers                         Dynamics.Forms.RmCashReceipts.RmCashReceipts.DeleteButton.ClickBeforeOriginal += new CancelEventHandler(DeleteButtonClickBeforeOrignal);
               Dynamics.Forms.RmCashReceipts.RmCashReceipts.DeleteButton.ClickAfterOriginal += new EventHandler(DeleteButtonClickAfterOrignal);   
               //Save button handlers
               Dynamics.Forms.RmCashReceipts.RmCashReceipts.SaveButton.ClickBeforeOriginal += new CancelEventHandler(SaveButtonClickBeforeOrignal);
               Dynamics.Forms.RmCashReceipts.RmCashReceipts.SaveButton.ClickAfterOriginal += new EventHandler(SaveButtonClickAfterOrignal);   
               //Open form handlers
               Dynamics.Forms.RmCashReceipts.RmCashReceipts.OpenBeforeOriginal  += new CancelEventHandler(FormOpenBeforeOrignal);
               Dynamics.Forms.RmCashReceipts.RmCashReceipts.OpenAfterOriginal += new EventHandler(FormOpenAfterAfterOrignal);
            }

           public void PostButtonClickBeforeOrignal(object sender, CancelEventArgs e)
           {
               MessageBox.Show("PostButtonClickBeforeOrignal");
           }

           public void PostButtonClickAfterOrignal(object sender, EventArgs e)
           {
               MessageBox.Show("PostButtonClickAfterOrignal");
           }  

           public void SaveButtonClickBeforeOrignal(object sender, CancelEventArgs e)
           {
               MessageBox.Show("SaveButtonClickBeforeOrignal");
           }

           public void SaveButtonClickAfterOrignal(object sender, EventArgs e)
           {
               MessageBox.Show("SaveButtonClickAfterOrignal");
           }

           public void FormOpenBeforeOrignal(object sender, CancelEventArgs e)
           {
               MessageBox.Show("FormOpenBeforeOrignal");
           }

           public void FormOpenAfterAfterOrignal(object sender, EventArgs e)
           {
               MessageBox.Show("FormOpenAfterAfterOrignal");
           }          

 

Update2:
 
Hi Vikas,

Thanks for the response.

I reinstalled the environment (GP2010 + GP2010 VS Tools) and got the same result - post button click handlers do not work and no exceptions are generated (please see the code below).

During the previous attempt I used GP2010 (11.00.1752 SP2) + VS2005 + GP10 VS Tools, currently I use the same GP2010 version +  VS2010 + GP2010 VS Tools.

Could anyone please check this code with GP2010(GP11)? Any other ideas are appreciated. Here is my code (save button handlers work properly, but post button click handlers do not work):

public void Initialize()

{

            try

{

                MessageBox.Show("Init event");

                //post button register handlers

                Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickBeforeOriginal += new CancelEventHandler(PostButtonClickBeforeOrignal);

                Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickAfterOriginal += new EventHandler(PostButtonClickAfterOrignal);

                //save button register handlers

                Dynamics.Forms.RmCashReceipts.RmCashReceipts.SaveButton.ClickBeforeOriginal += new CancelEventHandler(SaveButtonClickBeforeOrignal);

                Dynamics.Forms.RmCashReceipts.RmCashReceipts.SaveButton.ClickAfterOriginal += new EventHandler(SaveButtonClickAfterOrignal);

            }

            catch (Exception exc)

            {

                MessageBox.Show(String.Format("Exception: {0}", exc.Message));

            }

        }

        public static void PostButtonClickBeforeOrignal(object sender, CancelEventArgs e)

        {

            try

            {

                MessageBox.Show("Post button click before orignal");

            }

            catch (Exception exc)

            {

                MessageBox.Show(String.Format("Exception: {0}", exc.Message));

            }           

        }

        public static void PostButtonClickAfterOrignal(object sender, EventArgs e)

        {

            try

            {

                MessageBox.Show("Post button click after orignal");

            }

            catch (Exception exc)

            {

                MessageBox.Show(String.Format("Exception: {0}", exc.Message));

            }      

        }

        public static void SaveButtonClickBeforeOrignal(object sender, CancelEventArgs e)

        {

            try

            {

                MessageBox.Show("Save button click before orignal");

            }

            catch (Exception exc)

            {

                MessageBox.Show(String.Format("Exception: {0}", exc.Message));

            }

        }

        public static void SaveButtonClickAfterOrignal(object sender, EventArgs e)

        {

            try

            {

                MessageBox.Show("Save button click after orignal");

            }

            catch (Exception exc)

            {

                MessageBox.Show(String.Format("Exception: {0}", exc.Message));

            }

        }

Thanks, 

Dmitry Kutetsky.

*This post is locked for comments

  • Vikas Gupta Profile Picture
    Vikas Gupta 2,622 on at
    Re: GP2010 VS Tools - PostButton event handlers does not work.

    Hi,

      I have tried with your code as follows:-

         Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickBeforeOriginal +=new System.ComponentModel.CancelEventHandler(PostButton_ClickBeforeOriginal);

                Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickAfterOriginal +=new EventHandler(PostButton_ClickAfterOriginal);

    Both the triggers for the RM_Cash_Receipts.PostButton Working fine in my environment. i am using VS2010 and GP2010R2.

    As i suppose u need to try reset your environment and try again with the code. because there is no case occurs when trigger not fire. or you can check whether trigger getting resister in initialize block using Exception handler. i have tried with two more windows for post button event.

  • Dmitry Kutetsky Profile Picture
    Dmitry Kutetsky 105 on at
    Re: GP2010 VS Tools - PostButton event handlers does not work.

    Hi Vikas,

    Thank you for response,

    Please see the Update from me to orignal post.

    Can you please check this behaviour in your GP2010 environment (if you have it, of course :)), maybe it's some troubles with my environment (but I think no, because I checked it with different VS tools (10 and 2001) and with different components) .

    With best regards,

    Dmitry Kutetsky.

  • Dmitry Kutetsky Profile Picture
    Dmitry Kutetsky 105 on at
    Re: GP2010 VS Tools - PostButton event handlers does not work.

    Update

    Sorry, I missed the the register code (I missed it in orignal post):

    Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickBeforeOriginal += new CancelEventHandler(PostButtonClickBeforeOrignal);

    Dynamics.Forms.RmCashReceipts.RmCashReceipts.PostButton.ClickAfterOriginal += new EventHandler(PostButtonClickAfterOrignal);      

    I use this code in Initiliaze() method  and issue is still here.

  • Vikas Gupta Profile Picture
    Vikas Gupta 2,622 on at
    Re: GP2010 VS Tools - PostButton event handlers does not work.

    hi,

      you have created a function "PostButtonClickBeforeOrignal" but i haven't seen this function under any event registration. can you please cross check whether u have register all triggers properly.

    because you have create 6 trigger registration and top 2 have the reference of DeleteButtonClickBeforeOrignal, DeleteButtonClickAfterOrignal. but in function these two methods not exists.

    Regards

    Vikas Gupta

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