Showing results for 
Search instead for 
Do you mean 

Plugin / Tool? Assign Value based on Field Changed

New Member
Posts: 1
Country: United States

Plugin / Tool? Assign Value based on Field Changed

Hello everyone:


I'm new to Act development.  I read some of the info on the Act2010 SDK, got one of the control samples to work in the designer, but I can't make the connection to implement the necessary changes to make something work in the Contact Detail page.


I want to ASSIGN a field value to a field based on a calculated value of another field AFTER the user exits the field.


1) User modifies Field1 and leaves the field

2) My Code:  Field3 = Field1 + Field2


I saw some code about FieldChanged but I'm not sure what code is required.  I saw several examples showing login authentications, but the example context isn't clear as the user would already be logged in.



Is this right:


Create a class (based on which entity?)

Overload FieldChanged

   Look for the name of the field I'm monitoring

   Add code to set value if condition met



I'm using Visual Studio 2008 / C#.  Does anyone have any examples of complete code structure for this?

Nickel Super Contributor
Posts: 441
Country: UK

Re: Plugin / Tool? Assign Value based on Field Changed

In vb but:


Public Sub OnLoad(ByVal App As ActApplication) Implements IPlugin.OnLoad
        ActApp = App  'Store a referenct to ActApplication
        AddHandler ActApp.CurrentContactChanged, AddressOf ContactChanging
        AddHandler ActApp.CurrentContactChanged, AddressOf ContactChanged
    End Sub 'OnLoad


    Private Sub ContactChanging(ByVal sender As Object, ByVal e As System.EventArgs)
        'the contact is changing, try and remove the field changed handler
            RemoveHandler ActApp.ApplicationState.CurrentContact.Fields.FieldChanged, AddressOf FieldChanged
        Catch ex As Exception
        End Try
    End Sub

    Private Sub ContactChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        'the contact has changed, attach to your field changed events
        AddHandler ActApp.ApplicationState.CurrentContact.Fields.FieldChanged, AddressOf FieldChanged
    End Sub

    Private Sub FieldChanged(ByVal fieldName As String)
        'field has changed
        If fieldName = 'fill in the rest of your code here
    End Sub


Hope that gets you started.