Community
Showing results for 
Search instead for 
Do you mean 
Reply

Field Change event not firing

Nickel Elite Contributor
Posts: 508
Country: USA

Field Change event not firing

I know there are a few posts already about this, but there are still situations where this is not firing, and I'm wondering if anyone has found the correct "order" to make it happen.

 

Basically, when I click from contact to contact it's fine - it's when I go to a Contact from either the list view or by clicking on the contact name from a group view that it still does not seem to work.

 

Here's the test driver I have:

Public Sub OnLoad(ByVal App As ActApplication) Implements IPlugin.OnLoad
    ActApp = App  'Store a referenct to ActApplication
    AddHandler ActApp.AfterLogon, AddressOf ActApp_AfterLogon
    AddHandler ActApp.ViewLoaded, AddressOf ACTAPP_ViewLoaded
    AddHandler ActApp.CurrentViewChanged, AddressOf ActApp_CurrentViewChanged
    AddHandler ActApp.CurrentContactChanged, AddressOf ActApp_CurrentContactChanged
  End Sub

  Private Sub ActApp_CurrentViewChanged(ByVal Sender As Object, ByVal e As System.EventArgs)

    MessageBox.Show("CurrentViewChanged") 'seems to fire all the time where expected
    'ActApp.RefreshLoadedViews()
    AddHandler ActApp.ApplicationState.CurrentContact.ContactFields.FieldChanged, AddressOf Fields_FieldChanged
    'AddHandler ActApp.CurrentContactChanging, AddressOf ActApp_CurrentContactChanging

  End Sub

  Private Sub ActApp_CurrentContactChanged(ByVal Sender As Object, ByVal e As System.EventArgs)

    MessageBox.Show("CurrentContactChanged") 'seems to fire all the time where expected
    AddHandler ActApp.ApplicationState.CurrentContact.ContactFields.FieldChanged, AddressOf Fields_FieldChanged

  End Sub

  Private Sub Fields_FieldChanged(ByVal fieldName As String)

    MessageBox.Show("Field Changed:" & fieldName.ToString) 
'only when I first load and use the arrows to navigate does it work
' not on lookups or from lists or from group views 

 I've tried the RefreshLoadedViews a few places, but that either causes a loop in the ViewChanged, or it just does nothing.

 

Thanks...

Richard Brust
ACT! Certified Consultant
richard@rbrDataSolutions.com
Employee
Posts: 1,163
Country: USA

Re: Field Change event not firing

What version are you working in?


I have 12.1.181 installed currently and can reproduce the issue when moving from to a contact from the group view, but cannot when moving from the contact list to the contact details screen. One difference between what we have is when I register for the contact change event, I do it AfterLogon, which if I'm remember correctly from the most recent webinar is the ideal time to start doing any work with your plugin.


In version 12 and 13 I know the event won't fire for the first contact, it doesn't help much now but this is resolved in 14. I think you should be able to work around it by refreshing the view (as you've done), however I think a better time to do it may be in ViewLoaded, and in that event check to ensure it's the ContactDetail page so we're not refreshing unnecessarily. 

Matthew Wood
Act! SDK Support
Community Moderator
Nickel Elite Contributor
Posts: 508
Country: USA

Re: Field Change event not firing

This is running/testing on 13.0.401.0, but the end user is 2009, so I'm using 11.1 assemblies.

 

I'll change it to after logon, which I think I had at one time, but if I added the refresh, the field change was firing twice.  The end result is a custom History entry, which I don't want twice.

 

Also, I don't care about the first contact, which is My Record, they will only do this for clients.  I did have the view check in there as well, but removed it for the testing.

 

I'll change some things around based on your comments and see how it goes.  Thanks mucho!

Richard Brust
ACT! Certified Consultant
richard@rbrDataSolutions.com
Nickel Elite Contributor
Posts: 508
Country: USA

Re: Field Change event not firing

Dim newComment = "Matthew Wood is a genius!!!"

 

I think it was just a placement of the Handlers in the wrong place, along with the refresh in the wrong place.  So far, I've looked up contacts, clicked from a Group, and navigated, and it seems to be working, and just writing one History item.

 

I need to do a bit more testing, refreshing, etc, but at least I'm on the right path - so thanks again...

 

 

Richard Brust
ACT! Certified Consultant
richard@rbrDataSolutions.com