0

Tried to use custom code for populating multilist with sorted desired certain items of certain template sorted by publish date, after implementing code successfully, results in the multilist weren't as expected, however after debugging it turns out in the code the list has been successfully sorted but in the sitecore multilist it comes up sorted alphabetically only not as sorted in code , any idea what's wrong here ?

public class RelatedArticlesCustomSort : IDataSource
{
    public Item[] ListQuery(Item item)
    {
        Log.Info($"Start ListQuery with item {item}", typeof(RelatedArticlesCustomSort));
        item = Context.ContentDatabase?.GetItem("/sitecore/content/WorkZen/WorkZen/Home/Content");
        List<Item> relatedArticles = item?.Axes?.GetDescendants()?.Where(i => i.TemplateID.ToString().Equals("{DEDF4A7F-87CD-40F8-BA00-21F77313A044}")).ToList();
        Item[] relatedArticlesSorted = relatedArticles.OrderByDescending(d => d[FieldIDs.PublishDate]).ToArray();
        return relatedArticlesSorted;
    }
}

enter image description here

enter image description here

2
  • Did you check this? sitecore.stackexchange.com/questions/17318/… Commented Aug 16, 2022 at 13:59
  • yes, not quite what i was looking for, as morten is talking about creating a custom fieldtype not working on the multilist OOTB fieldtype, also missing some info about that part " (add controlsource to config file and create the fieldtype in core database)" Commented Aug 16, 2022 at 14:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.