06-09-2015 10:17 AM
hi,
I have a problem.
I want to fire an Event when a field is changed but when i switch to List view and come back to Detail View the event handler don't fire.
void IPlugin.OnLoad(ActApplication application)//au chargement { this.application = application; application.AfterLogon += new EventHandler(Application_AfterLogon); application.BeforeLogoff += new EventHandler(Application_BeforeLogoff); application.CurrentOpportunityChanged += new EventHandler(application_CurrentOpportunityChanged); application.CurrentViewChanged+=application_CurrentViewChanged; ACTFM = application.ActFramework; } private void application_CurrentViewChanged(object sender, EventArgs e) { if (application.CurrentViewName == typeof(Act.UI.IContactDetailView).FullName) { // attach events application.CurrentContactChanged += application_CurrentContactChanged; application.CurrentContactChanging += application_CurrentContactChanging; application.ApplicationState.CurrentContact.Fields.FieldChanged += Fields_FieldChanged; } else { // detatch events Contact contact = application.ApplicationState.CurrentContact; if (contact != null) { application.CurrentContactChanged -= application_CurrentContactChanged; application.CurrentContactChanging -= application_CurrentContactChanging; application.ApplicationState.CurrentContact.Fields.FieldChanged -= Fields_FieldChanged; } } } private void application_CurrentContactChanging(object sender, EventArgs e) { application.ApplicationState.CurrentContact.Fields.FieldChanged -= Fields_FieldChanged; } private void application_CurrentContactChanged(object sender, EventArgs e)//au changement de contact dans act { var c = application.ApplicationState.CurrentContact; cs.ListRegistrationUpdate(); cs.SetValues(); cs.MiseAJour(c); cs.SetValues(); c.Fields.FieldChanged += Fields_FieldChanged; } private void Fields_FieldChanged(string fieldName) { MessageBox.Show("Field Changed"); }
06-10-2015 10:09 AM
If you are using your original code posted it does not include the refresh.
this.ACTApplication.RefreshView(this.ACTApplication.CurrentViewName);
-- Jim Durkin
06-09-2015 11:14 AM
I think its still a bug in ACT!.
Try walking off the startup record. Does the event fire now?
-- Jim Durkin
06-09-2015 11:24 AM
Sorry but I dont't understand what you want to say??
"Try walking off the startup record. Does the event fire now?"
06-09-2015 11:31 AM
06-09-2015 11:34 AM
Yep it works.
On your link I saw "force a refresh/save as soon as the database has opened and from that point forward all event should fire normally."
But I don't know how to...
06-09-2015 12:46 PM
06-09-2015 01:15 PM
It doesn't change anything, when I change contact it works but when I change view and not contact it continue to doesn't work...
06-09-2015 02:03 PM
This code is ripped out of Impact Suite. Not positive it will run out-of-the-boc but it should give you direction.
Private Sub RefreshCurrentView(ByVal Sender As Object, ByVal e As System.EventArgs) '----------------------------------------------------- ' Add the current event handlers '----------------------------------------------------- Try Select Case HostApplication.CurrentViewName Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.ContactDetailViewName If Me.UIMathEventLoadedContacts = False Then If Not (Me.HostApplication.ApplicationState.CurrentContact Is Nothing) Then Me.UIMathEventLoadedContacts = True AddHandler Me.HostApplication.CurrentContactChanged, AddressOf Math_CurrentContactChanged End If End If Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.CompanyDetailViewName If Me.UIMathEventLoadedCompanies = False Then If Not (Me.HostApplication.ApplicationState.CurrentCompany Is Nothing) Then Me.UIMathEventLoadedCompanies = True AddHandler Me.HostApplication.CurrentCompanyChanged, AddressOf Math_CurrentCompanyChanged End If End If Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.GroupDetailViewName If Me.UIMathEventLoadedGroups = False Then If Not (Me.HostApplication.ApplicationState.CurrentGroup Is Nothing) Then Me.UIMathEventLoadedGroups = True AddHandler Me.HostApplication.CurrentGroupChanged, AddressOf Math_CurrentGroupChanged End If End If Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.OpportunityDetailViewName, Durkin.Common.Classes.ACTUIToolkit.ACTViews.OpportunityViewName If Me.UIMathEventLoadedOpportunities = False Then If Not (Me.HostApplication.ApplicationState.CurrentOpportunity Is Nothing) Then Me.UIMathEventLoadedOpportunities = True AddHandler Me.HostApplication.CurrentOpportunityChanged, AddressOf Math_CurrentOpportunityChanged End If End If End Select xxx() Catch ex As System.Exception LogError.Write(ex, "MATH:RefreshCurrentView") End Try End Sub Private Sub Math_CurrentContactChanged(ByVal sender As Object, ByVal e As System.EventArgs) Try RemoveHandler Me.HostApplication.ApplicationState.CurrentContact.Fields.FieldChanged, AddressOf Math_FieldChanged AddHandler Me.HostApplication.ApplicationState.CurrentContact.Fields.FieldChanged, AddressOf Math_FieldChanged Catch ex As System.Exception LogError.Write(ex, "MATH:Application_CurrentContactChanged") End Try End Sub Private Sub Math_FieldChanged(ByVal fieldName As String) Try Select Case HostApplication.CurrentViewName Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.ContactDetailViewName ' Your code here! Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.CompanyDetailViewName Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.GroupDetailViewName Case Durkin.Common.Classes.ACTUIToolkit.ACTViews.OpportunityDetailViewName, Durkin.Common.Classes.ACTUIToolkit.ACTViews.OpportunityViewName End Select Catch ex As System.Exception LogError.Write(ex, "MATH:Math_FieldChanged") End Try End Sub
Hope this helps
-- Jim Durkin
06-10-2015 07:19 AM
It doesn't work ...
I have always the same problem.
06-10-2015 09:59 AM