Showing results for 
Search instead for 
Do you mean 

Validate Field

Tuned Listener
Posts: 10
Country: Brazil

Validate Field


I´m writing my second plugin (for ACT 2007).
The first one worked fine, I was able to run, debug, etc.

Now I need to write a plugin that must validate a specific text field when the user gets out of the field.
From the SDK samples I'm using the code below, with the insertion of the AddHandler for the sub Actapp_FieldLeave,
but the sub is never fired.
Is this the correct way to do this job ? Is there another way to do that ?

Thanks in advance

Imports System
Imports System.Windows.Forms
Imports Act.Framework.Contacts
Imports Act.Framework.Histories
Imports Act.UI

Public Class Class1
Implements IPlugin

Public Sub New()

End Sub

Public Sub OnLoad(ByVal App As ActApplication) Implements IPlugin.OnLoad
ActApp = App 'Store a reference to ActApplication
AddHandler ActApp.AfterLogon, AddressOf ActApp_AfterLogon
AddHandler ActApp.BeforeLogoff, AddressOf ActApp_BeforeLogoff
AddHandler ActApp.Leave, AddressOf Actapp_FieldLeave
End Sub 'OnLoad


Private Sub Actapp_FieldLeave(ByVal Sender As Object, ByVal e As System.EventArgs)
'This code was expected to fire when the user clicks outside a field
End Sub

Private Sub ActApp_AfterLogon(ByVal Sender As Object, ByVal e As System.EventArgs)
'This code is fired as expected
End Sub

Private Sub ActApp_BeforeLogoff(ByVal Sender As Object, ByVal e As System.EventArgs)
'This code is fired as expected
End Sub

End Class
Copper Contributor
Posts: 98
Country: United States

Re: Validate Field

[ Edited ]
Try 'signing up' for a CurrentContactChanged event ...
which traps a FieldChanged event ...
which then handles which field has changed.
I know this works.
 private void AfterLogon(object Sender, System.EventArgs e)
                AddMenuItem("act-ui://com.act/application/menu/tools/Test", "Trap", new Act.UI.CommandHandler(this.Test01));
                ActApp.ActFramework.Database.BeforeDatabaseLock += new Act.Framework.Database.DatabaseLockHandler(this.BeforeDatabaseLock);
                ActApp.CurrentContactChanged += new EventHandler(ActApp_CurrentContactChanged);
            catch (Exception ex)

        void ActApp_CurrentContactChanged(object sender, EventArgs e)
            ActApp.ApplicationState.CurrentContact.Fields.FieldChanged += 
                   new Act.Framework.MutableEntities.MutableEntity.FieldCollection.FieldChangedHandler(Fields_FieldChanged);

        void Fields_FieldChanged(string fieldName)
            switch (fieldName)
                case "TBL_CONTACT.EXAMPLE":  


Sorry for the C#

Message Edited by Carlton_Jones on 04-04-2008 05:03 PM
Carlton Jones
Sage Software
Tuned Listener
Posts: 10
Country: Brazil

Re: Validate Field

Thanks a lot for your answer. That's worked, but actualy is not exactly what I need. The CurrentContactChanged fires at every character typed, but I must check the field only when the user is finished typing data. Any other idea ?
Bronze Elite Contributor
Posts: 2,119
Country: United_Kingdom

Re: Validate Field



Maybe you could use the Act.MutatableEntities.MutatableEntity.Update Event? Act.Framework.Contact inherits from MutatableEntity. I think the Update event is fired when the Contact is commited to the dB so this would be after the Save is accepted fro the Contact.




Vivek Gargav
Caldere Associates Ltd.
My Blog