Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paria 4 posts 24 karma points
    Apr 11, 2024 @ 14:25
    Paria
    0

    Dynamic Root issue

    I was thrilled to use Dynamic Root in Umbraco 13 to solve one of my issues about ordering data in a multi-tree picker, but, so disappointed now! My code is:

     public class DynamicArticlesOrderQueryStep : IDynamicRootQueryStep
     {
         private readonly IContentService _contentService;
    
         public DynamicArticlesOrderQueryStep(IContentService contentService)
         {
             _contentService = contentService;
         }
    
         public async Task<Attempt<ICollection<Guid>>> ExecuteAsync(ICollection<Guid> origins, DynamicRootQueryStep filter)
         {
             await Task.CompletedTask;
    
             if (filter.Alias != "OrderArticleByDate")
                 return Attempt<ICollection<Guid>>.Fail();
    
             if (origins.Any() is false)
                 return Attempt<ICollection<Guid>>.Succeed(Array.Empty<Guid>());
    
             var contentItems = _contentService.GetByIds(origins);
    
             if (contentItems.Any() is false)
                 return Attempt<ICollection<Guid>>.Fail();
    
             var articles =
                 _contentService
                 .GetPagedChildren(contentItems.FirstOrDefault().Id, 0, 10, out long totalRecords, null, Ordering.By("UpdateDate", Direction.Descending));
    
             if (articles.Any())
                 return Attempt<ICollection<Guid>>.Succeed(articles.Select(x => x.Key).ToList());
    
    
             return Attempt<ICollection<Guid>>.Succeed(Array.Empty<Guid>());
         }
     }
    

    my picker setting: enter image description here I have no result coming back in the picker, and there is no error in the console or anywhere, when I debug I can see 10 Guids which are correct answers but nothing in back office coming back, did I miss a step? (I did register it by the composer)

    I am using Umbraco version 13.2.2.

  • Luuk Peters 85 posts 330 karma points
    May 01, 2024 @ 07:15
  • Paria 4 posts 24 karma points
    May 02, 2024 @ 09:04
    Paria
    0

    Don't think so, as it says in the end it worked after refreshing mine never returned any items even when I debug ids were there!

  • edwich44 18 posts 94 karma points
    1 week ago
    edwich44
    0

    I had the same issue and found out, that unfortunately, you can only return parent Ids and the Multinode Picker will then return the children.

    E.g. if you had a parent folder called Articles, you need your custom IDynamicRootQueryStep to return the Id of Articles, rather than child article Ids.

Please Sign in or register to post replies

Write your reply to:

Draft