Community
Showing results for 
Search instead for 
Do you mean 
Reply

Accessing a custom field

Accepted Solution Solved
gkl
Copper Contributor
Posts: 29
Country: Ecuador
Accepted Solution

Accessing a custom field

I am new to Act and i haveadded some custom fields in the contacts. Tools->Define Fields->Create New Field and created a new field called abc. In addtion i have modified the Layout that it shows my custom field called abc.

Now i want to acces this custom field called abc and return its values programmatically (c#).

Is there a way to get custom fields  by name, or get the act field id as u loop through the contacts;

 


for (int i = 0; i < cfdList.Count; i++)
{

Contact cfd = cfdList[i];
customfield = customefield +  " " + cfd.??????;

}


Accepted Solutions
Solution
Accepted by topic author gkl
‎09-25-2015 03:20 AM
Copper Contributor
Posts: 123
Country: Canada

Re: Accessing a custom field

This is the way I do it but there could be better ways.

 

 

You would want to get the ContactFieldDescriptor first:

 

ContactFieldDescriptor abcField = actFwk.Contacts.GetContactFieldDescriptor("abc", FieldNameType.Alias);

 

 

If you want to display the text value of the field you could do something like:

 

MessageBox.Show(abcField.GetValue(cfd).ToString());

 

 

You can also set the field value on the contact by using something like:

 

cfd.Fields["abc", FieldNameType.Alias] = yourvalue;
cfd.Update();

 

 

Hope that helps a bit.

View solution in original post


All Replies
Solution
Accepted by topic author gkl
‎09-25-2015 03:20 AM
Copper Contributor
Posts: 123
Country: Canada

Re: Accessing a custom field

This is the way I do it but there could be better ways.

 

 

You would want to get the ContactFieldDescriptor first:

 

ContactFieldDescriptor abcField = actFwk.Contacts.GetContactFieldDescriptor("abc", FieldNameType.Alias);

 

 

If you want to display the text value of the field you could do something like:

 

MessageBox.Show(abcField.GetValue(cfd).ToString());

 

 

You can also set the field value on the contact by using something like:

 

cfd.Fields["abc", FieldNameType.Alias] = yourvalue;
cfd.Update();

 

 

Hope that helps a bit.

gkl
Copper Contributor
Posts: 29
Country: Ecuador

Re: Accessing a custom field

Thanks!!!That did it