04-22-2008 06:41 AM
Ive been searching through the forums and can't really find a solution to this problem. Hopefully someone can help me out or at least point me to a thread with the answer. We have an ACT database that has some custom fields defined. I cycled through the contact field descriptors and the table name and column name show up like "TBL_CONTACT.TypeofContact_393843394" for the Type of Contact custom field. Yet when I try to access it I get that the column does not exist. Can anyone tell me how to access the custom fields in ACT programmatically?
Thanks in advance,
04-22-2008 06:59 AM - edited 04-22-2008 09:51 AM
Probably what you're looking for is TBL_CONTACT.CUST_TypeofContact_393843384
However, a good way to avoid this problem in the future is to reference fields by their display name rather than their 'real' name
public ContactFieldDescriptor GetContactFieldDescriptor( string name, bool isReal );
cField = ActFwk.Contacts.GetContactFieldDescriptor("Contact.User 1", false); //DISPLAY
cField = ActFwk.Contacts.GetContactFieldDescriptor("TBL_CONTACT.USER1", true); //REAL
So for instance rather than trying to type out all those number for the 'real' name of the field, try getting the field like this
cField = ActFwk.Contacts.GetContactFieldDescriptor("Contact.TypeofContact", false);
note the 'false' for the second argument since we are passing the display name of the field.
07-17-2008 12:57 PM
I am having a problem accessing a custom field as suggested above. I have a custom field named "Advisor"
Try Dim cField As ContactFieldDescriptor = ActApp.ActFramework.Contacts.GetContactFieldDescriptor("Contact.Advisor", False) oValue = cField.GetValue(cContact) MessageBox.Show("Advisor Name = " & oValue.ToString()) Catch ex As Exception MessageBox.Show("Advisor Name Error " & vbCrLf & ex.ToString) End Try
The error I get is:
"Act.Framework.MutableEntityMetaDataArgumentException: Invalid column name: Advisor"
The plugin works when I access the custom field on my system but does not when I access the shared database for our company.
07-17-2008 01:57 PM
Possibly the 'display name' isn't 'Advisor' on the main company database.
It could be labeled as 'Advisor' on the layout but underneath (aka define fields) it could be called something else.
07-18-2008 02:13 AM
Private Sub ChangeAddress() Dim cContact as act.framework.contacts.contact = Actapp.ApplicationState.CurrentContact cContact.Fields(GetField("Address 1"),True) = "39 The Street" cContact.update() End Sub Private Function GetField(Byval strDispName as string) as string Dim cFields() as act.framwork.contacts.contactfielddescriptor = _ ActApp.actframework.contacts.getcontactfielddescriptiors For each field as act.framework.contacts.contactfielddescriptor in cfields if field.displayname = strDispName then return field.name end if Next End Function
07-08-2014 01:53 PM
This works really nice but how u can loop through contacts n display the custom field; My custom field has a name called Links, so i use the below code folldowing your example
ContactFieldDescriptor asdfff = ACTFM.Contacts.GetContactFieldDescriptor("CONTACT.Links", false);
For example i use this code below to get the contact Names.Ηοw should I modify my code to get the cfd Links;
string allnames = "";
for (int i = 0; i < cfdList.Count; i++)
Contact cfd = cfdList[i];
allnames = allnames + " " + cfd.FullName;