6

I'm using ISitecoreService (Glass.Sitecore.Mapper, Version=2.0.11.0) to save a glass item defined like this in Sitecore.NET 6.6.0 (rev. 130111):

[SitecoreClass(false,"{3ACCADE1-C482-422C-9A22-3479C661B6AD}")]
public partial interface IAnnouncementInfoItem:ISitecoreItem        
{   
    [SitecoreField(FieldName = "Announcement Text",CodeFirst = false)]
    string AnnouncementText { get; set; }   

    [SitecoreField(FieldName = "Working Groups",CodeFirst = false)]
    IEnumerable<Guid> WorkingGroups { get; set; }       
}

I'm running into an issue with the MultiList (mapped as IEnumerable<Guid>) where each value shows up as "Not in List" even though the value is clearly in the source.

enter image description here

The Guids match up correctly with the items defined in the source. It even finds the names of the values correctly. The only difference I have found between the items saved through SitecoreService and those saved from Content editor is that the Guids are saved as lowercase values when saved from SitecoreService. enter image description here

Has anyone ran into this issue before? It seems like there is some case sensitivity happening but not sure if this is a bug in Sitecore, GlassMapper or something else entirely.

Update

When saving the item I'm passing in some text and a list of Guids:

public void SaveAnnouncement(Guid announcementId, string text, IList<Guid> workingGroupIds)
    {
        var announcementItem =
            _srcItem.AnnouncementsFolderItem.GetChildrenOfType<IAnnouncementItem>().FirstOrDefault(c => c.Id == announcementId);
        announcementItem.AnnouncementText = text;
        announcementItem.Name = ItemUtil.ProposeValidItemName(text);
        announcementItem.WorkingGroups = workingGroupIds ?? new List<Guid>();
        using (new SecurityDisabler())
        {
            //wrapper on SitecoreServiceMaster
            _dependencies.GlassSitecoreServiceManager.Master.Save(item);
        }
    }
  • Could you show us your code where you're populating your WorkingGroups property and saving the item? – Corey Smith Oct 24 '16 at 13:48
  • Are there template id and item id attributes for that model you are saving? – ASura Oct 24 '16 at 14:10
  • Can you try converting the Glass guid to upper case, I wonder if the tool that does check is case sensitive – Michael Edwards Oct 24 '16 at 14:19
  • @ASURA yes the templateId and itemId attributes exist on the model correctly. It does also save but there is just the problem with this particular field type – Rondel Oct 24 '16 at 14:21
  • @MichaelEdwards Since I'm working with Guids and not strings I don't have the ability to specify casing for the save. I could potentially try changing the model to use strings and set uppercase GUID strings explicitly but I would rather leave the actual type in place if possible – Rondel Oct 24 '16 at 14:24
4

I had a similar issue and it was originated by the Guids. The multilist fields should store IDs instead of Guids. You can do the following:

  1. Remove all your selected items and add them manually.
  2. Save your changes and verify your raw values are IDs.
  3. Debug your solution and you will see that your items will be mapped.

If you are adding items programmatically, you should add IDs (new ID(Guid/string))

| improve this answer | |
  • Changing the GlassModel to use IDs instead of Guids seems to have done the trick. Thanks! – Rondel Oct 25 '16 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.