04-20-2012 09:19 AM
I am using VB.Net with Act.Framework.dll to develop some integration applications. My client has created a number of custom Contact fields in hist ACT! database. eg. TargetLink. If I want to update these fields I currently use a line similar to this:
actCont.ContactFields("CUST_ContactsTable1_080250.CUST_TargetLink_030704295", True) = "link to a website"
My question is this: can I refer to these fields in my code using a friendlier name rather than having to look them up in actdiags.exe? Ideally something like:
actCont.ContactFields(TargetLink, True) = "link to a website"
04-20-2012 11:26 AM
I created a function to do that. This function takes takes two parameters: Framework and the Dispyaname of the field. It returns the ContactFieldDescriptor
Public Shared Function GetContactFieldDescriptorByDisplayName(ByVal HostFramework As Act.Framework.ActFramework, ByVal sDisplayName As String) As Act.Framework.Contacts.ContactFieldDescriptor '------------------------------------------------------------ ' Check all fields in the GetContactFieldDescriptors ' And return the ONE where sDisplayName = cField1.DisplayName '---------------------------------------------------------------- For Each cField1 As Act.Framework.Contacts.ContactFieldDescriptor In HostFramework.Contacts.GetContactFieldDescriptors() If sDisplayName.ToUpper = cField1.DisplayName.ToUpper Then Return cField1 Exit For End If Next Return Nothing End Function
'To use the function, init a field descriptor....
Dim CustomContactFieldDescriptor As Act.Framework.Contacts.ContactFieldDescriptor = nothing
' Get the field descriptor using the current ACT framework and the display name of the field
CustomContactFieldDescriptor = GetContactFieldDescriptorByDisplayName(ACTAPP.ACTFramework, "link to a website")
'Get the value of that field from the currentContact
Dim strLinkToWebsite as string = CustomContactFieldDescriptor.Getvalue(ACTAPP.ApplicationState.CurrentContact)
Hope this helps
-- Jim Durkin