Community
Showing results for 
Search instead for 
Do you mean 
Reply

Accessing a custom field

New Member
Posts: 3
Country: USA

Accessing a custom field

Hi,

 

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,

 

Mark

Copper Contributor
Posts: 98
Country: United States

Re: Accessing a custom field

[ Edited ]

Hey Mark,

 

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

 

  
[C#]

public ContactFieldDescriptor GetContactFieldDescriptor( string name, bool isReal );

//Example 1
ContactFieldDescriptor cField;
cField = ActFwk.Contacts.GetContactFieldDescriptor("Contact.User 1", false); //DISPLAY

//Example 2
ContactFieldDescriptor cField;
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.

 

HTH,

EDIT: Confused Alias and Display name... corrected.
NOTE: Display name can change.
Message Edited by Carlton_Jones on 04-22-2008 12:51 PM
Carlton Jones
Sage Software
New Member
Posts: 3
Country: USA

Re: Accessing a custom field

Thanks. Worked like a charm.

 

Mark

New Member
Posts: 9
Country: USA

Re: Accessing a custom field

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.

 

Any ideas?

 

Thanks,

 

Russell

Copper Contributor
Posts: 98
Country: United States

Re: Accessing a custom field

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.

 

 

Carlton Jones
Sage Software
Nickel Super Contributor
Posts: 441
Country: UK

Re: Accessing a custom field

The field may be in a spillover table, try using "Contact Table 1.Advisor,False".  Beacuse of the problems with spilliover tables I try and use real names or alisaes.  I use the sample below if I nead a field name rather than using the False paramater.

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

Tom

New Member
Posts: 9
Country: USA

Re: Accessing a custom field

I have addthe code to my plugin to display the field name and the display name.  I will let you know the results.  Thanks for the help!!
gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Accessing a custom field

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;


}