1
votes

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
1
If you turn Raw Values on, how are the values stored? Is it a pipe-delmited list of ID's or something else?DougCouto
Yes, pipe-delimited list of ID'scrjunk
Then, yes, as you've probably confirmed, all you were missing was the call to GetItems().DougCouto

1 Answers

1
votes

You are very close .. you need to call the GetItems() method (instead of the Items property) which will resolve the item ID's into an array of Sitecore Item objects.

You can then call properties such as item.Name or retrieve a specific field using .. item.Fields[FieldName].Value.