10-13-2009 08:30 AM
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?)
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?
10-15-2009 01:47 AM
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
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
Private Sub FieldChanged(ByVal fieldName As String)
'field has changed
If fieldName = 'fill in the rest of your code here
Hope that gets you started.