I am working with the Client Side Object Model. In a console application I am retrieving all fields from a custom list. The problem is the Clientcontext fetches me a bunch of internal fields I do not want to be included. Also this causes some of the fields to appear more than once.
string siteURL = "http:XYZ";
ClientContext context = new ClientContext(siteURL);
Web oWebSite = context.Web;
context.Load(oWebSite);
context.ExecuteQuery();
//Get the list by title
List produktKatalogListe = spLists.GetByTitle("Produktkatalog");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View/>";
ListItemCollection listItems = produktKatalogListe.GetItems(camlQuery);
context.Load(produktKatalogListe);
context.Load(listItems);
context.Load(produktKatalogListe.Fields);
context.ExecuteQuery();
foreach(Field field in produktKatalogListe.Fields)
{
Console.WriteLine("{0} - {1} - {2} - {3} - {4}",field.Title,field.InternalName,field.Hidden,field.CanBeDeleted,field.FieldTypeKind);
}
Is there a way to print only custom fields? This would mean omitting fields like internalID
, GUID
...
I tried the following:
if(!field.Hidden)
{
Console.WriteLine("{0} - {1} - {2} - {3} - {4}",field.Title,field.InternalName,field.Hidden,field.CanBeDeleted,field.FieldTypeKind);
}
Unfortunately this not only does not solve the issue but is also not a very good solution for the case I do want to display custom but hidden fields.