I am developing a web part in C# which is reading the contents of a SharePoint list.
I can retrieve the values in all the fields I need, except the Target Audience field (which uses AD security groups). I have tried various ways to access this e.g.
string myItem = Convert.ToString(ListItem.properties[“Audience”])
but all I get is null returned. I can see that a target group has been stored in the fueield for thwe item when I edit the item in SharePoint.
How can I retrieve the contents of this field using code?
Try not using the
Propertiesof theListItem, but the fields themselves.In the “Target Audience” field you have some GUIDs stored as strings, these you need to retrieve like so:
afterwards you might want to look at
audience.GetMembership().