Question Status

Unanswered
Dmitry Kutetsky asked a question on 21 Feb 2012 4:22 AM

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.

Reply
Vikas Gupta responded on 23 Feb 2012 11:17 AM

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

Reply
Dmitry Kutetsky responded on 27 Feb 2012 3:09 AM

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.

Reply
Dmitry Kutetsky responded on 27 Feb 2012 3:16 AM

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.

Reply
Vikas Gupta responded on 1 Mar 2012 10:14 PM

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.

Reply