I want to retrieve the existing field groups (from root) and display them in a dropdown list.
I'm using this code to retrieve all the columns (and display which group 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 a few hundred groups (duplicates ofc), I want to narrow it down to just the few groups that exist, and sort out the duplicates. Or is there another way to do this?