Closed simonlongson closed 9 years ago
For now what I'm doing is adding in the custom fields into the contact.cs structure
[XmlRpcMember("_Status")]
[Access(Access.Edit | Access.Delete | Access.Add | Access.Read)]
public string _Status { get; set; }
This is a fix but I'd rather not clog up the Contact.cs file with all these extra fields, especially as I'm not able to get into IS to check field types, making this a very labour intensive job (adding field checking it works and changing type if not, for 30+ fields).
[XmlRpcMember("_Status")]
[Access(Access.Edit | Access.Delete | Access.Add | Access.Read)]
public dynamic _Status { get; set; }
seems to work so I'll just continue down that route. Hopefully this will help someone else out.
Would still like to know if there's a built in way to read the custom fields though. Cheers
There are extention methods in the projection for Custom Fields. use IncludeCustomField(string fieldName)
The sample Shows p.Include(c => c.Id)
I think you can add p.IncludeCustomField("status")
to the projection, and you'll get that custom field back.
The Contact Table inherits from an abstract class Table, which has a property of CustomFields, you're value should be in there waiting for you. Is it not?
public IDictionary<string, object> CustomFields
{
get { return _customFields; }
}
Yeah I'm using the following from that sample.
//Find contact vanilla api style
var contacts2 = client.ContactService.FindByEmail(email, new[] {"Id", "Email"});
I'm getting the custom fields back in the xml but I didn't know how to call them in the code. I'm guessing they don't get added to the customFields dictionary unless used the way you've pointed out though. Thank you I'll look into that
That's right, the CustomFields projection adds them correctly on the return payload, where the string[] ignores the unknown fields. So they're coming back, they just don't have a home.
Enjoy the project!
Perfect thank you. Will do. It's been a live saver so far :-)
That in a nut shell will query contact table using the email and return _Status back. Now when I run it I can see in the response the customField but I can't select it. I'm I doing something daft?