Odd behavior when selecting customer code in different way (Customization)

SOLVED

Hi All,

I am doing customization  on few standard Sage 200 forms, and I found an odd behavior when selecting customer code in different way.

For example, on Sales Ledger>New Invoice, we can select customer code in 3 methods: 

1. click dropdown and select the customer code.

2. type in customer code and tab away

3. type in customer code and click outside of the customer code area (to be exact CustomerInvoiceLookup field.)

My customization works like this:

once user select customer code, I capture the event with CustomerSelected(), check if the exchange rate has expired, and let user decide what to do next.

If user click "Yes", then proceed. This is not a problem.

If user click "No", then I will close the form by calling closeButton.performClick(). It work well if I use method 1. But for methods 2 and 3, it did not work.

Then I monitor the standard event:

Using method 1, these are the event triggered.

Using method 2 and 3, these are the event triggered

All methods have CustomerSelected event but only method 1 works ok. I have used CustomerChanged and Leave, but it still the same. Anyone knows why? Thank you.

Parents
  • 0

    A couple of extra points:

    1. Rather than closing the form, it would be easier to follow the same pattern as Sage does for an account on hold: just clear the customerInvoiceLookup.  But I guess the spec says "Close the form"!

    2. Don't forget that the form can be launched with the customer preselected (eg. from a workspace or desktop list) in which case the CustomerSelected event doesn't fire.

    Good luck!

  • 0 in reply to Geoff Turner

    Hi Geoff, yes I got problem on point 2- I cannot catch the preselected customer on screen. Unable to monitor event as well to see which event are triggered. Any tips on how to catch it once customer is preselected?

  • 0 in reply to murni

    Add a handler for the form Shown event (you'll have to cast form.UnderlyingObject), and in the handler do this:

    private void MyTestForm_Shown(object sender, EventArgs e)
    {
        if(customerInvoiceLookup.Customer != null && 
            !customerInvoiceLookup.Customer.PrimaryKey.IsNull)
        {
            //do stuff
        }
    }

Reply
  • 0 in reply to murni

    Add a handler for the form Shown event (you'll have to cast form.UnderlyingObject), and in the handler do this:

    private void MyTestForm_Shown(object sender, EventArgs e)
    {
        if(customerInvoiceLookup.Customer != null && 
            !customerInvoiceLookup.Customer.PrimaryKey.IsNull)
        {
            //do stuff
        }
    }

Children