Retrieve field groups from SharePoint CSOM -
Retrieve field groups from SharePoint CSOM -
i want retrieve existing field groups (from root) , display them in dropdown list.
i'm using code retrieve columns (and display grouping they're belonging to):
var web = clientcontext.web; fieldcollection rootfields = web.fields; clientcontext.load( rootfields, fields => fields .include(field => field.group) ); clientcontext.executequery(); foreach (field _fields in rootfields) { fieldslist.add(new selectlistitem { text = _fields.group }); }
this shows few hundred groups (duplicates ofc), want narrow downwards few groups exist, , sort out duplicates. or there way this?
you can via linq:
distinct sort duplicates out of result.
var results = rootfields.tolist().select(field => field.group).distinct(); foreach (var_group in results) { fieldslist.add(new selectlistitem { text = _group }); }
sharepoint-2013 csom
Comments
Post a Comment