I have an item in Sitecore that contains a content section which is a Checklist. This checklist contains the names of multiple Active Directory groups that I have entered into Sitecore.
When the item loads, I am trying to loop through all of the names that are in the Checklist so that I can see if the user is a member of one of these groups, if checked.
When testing my code, I cannot obtain the ID’s “display” value (not sure if this is the correct termonology), such as “IT_Support_Group”. Instead, I can only get the Item Id.
Example: {80B1AEEA-D36C-416C-B5BF-AF5F428E4D31}
I’ve been playing around with various versions of the following code, but with no luck:
Dim ADCheckList As Sitecore.Data.Fields.MultilistField = Sitecore.Context.Item.Fields("ADGroupAccess")
If ADCheckList IsNot Nothing Then
For Each ADListName As String In ADCheckList.Items
'If IsInGroup(ADListName) and IsADListItemChecked(ADListName) Then
' Response.Write("User is in the " & ADListName & " selected group.<br/>"
'End If
Next
End If
You are very close .. you need to call the
GetItems()method (instead of theItemsproperty) which will resolve the item ID’s into an array of SitecoreItemobjects.You can then call properties such as
item.Nameor retrieve a specific field using ..item.Fields[FieldName].Value.