I am having trouble retrieving custom fields from the contact table.
I do not receive any error on this issue – I just do NOT receive the values for the custom fields that I am requesting.
If I add a normal property like FirstName into SelectedFields then do receive its value back.
I am using custom fields that I know are populated for the contact id in question, so I definitely should be receiving values back.
Here is my calling code for ContactService.Load:
public string RetrieveCustomFieldFromContact(int contactID, string customFieldName)
{
const string methodName = "RetrieveCustomFieldFromContact";
var fieldValue = string.Empty;
var customer = new Customer(Constants.InfusionSoftApplicationName, Constants.InfusionSoftAPIKey);
var proxy = customer.Connect();
try
{
if (!customFieldName.StartsWith(""))
{
customFieldName = "" + customFieldName;
}
string[] selectedFields = { customFieldName };
var response = proxy.ContactService.Load(contactID, selectedFields);
if (response.CustomFields.ContainsKey(customFieldName))
{
fieldValue = response.CustomFields[customFieldName].ToString();
}
}
catch (Exception ex)
{
_utility.Log(LoggingType.Error, string.Format("{0} - An error occurred {1}", methodName, ErrorHelper.GetExceptionDetails(ex)));
}
return fieldValue;
}
I am having trouble retrieving custom fields from the contact table.
I do not receive any error on this issue – I just do NOT receive the values for the custom fields that I am requesting. If I add a normal property like FirstName into SelectedFields then do receive its value back. I am using custom fields that I know are populated for the contact id in question, so I definitely should be receiving values back. Here is my calling code for ContactService.Load:
public string RetrieveCustomFieldFromContact(int contactID, string customFieldName) { const string methodName = "RetrieveCustomFieldFromContact"; var fieldValue = string.Empty; var customer = new Customer(Constants.InfusionSoftApplicationName, Constants.InfusionSoftAPIKey); var proxy = customer.Connect(); try { if (!customFieldName.StartsWith("")) { customFieldName = "" + customFieldName; } string[] selectedFields = { customFieldName }; var response = proxy.ContactService.Load(contactID, selectedFields); if (response.CustomFields.ContainsKey(customFieldName)) { fieldValue = response.CustomFields[customFieldName].ToString(); } } catch (Exception ex) { _utility.Log(LoggingType.Error, string.Format("{0} - An error occurred {1}", methodName, ErrorHelper.GetExceptionDetails(ex))); } return fieldValue; }