cq:lastReplicationAction not usable on AEM Publish/Dispatcher - component renders empty | Community
Skip to main content
Level 2
August 12, 2026
Question

cq:lastReplicationAction not usable on AEM Publish/Dispatcher - component renders empty

  • August 12, 2026
  • 2 replies
  • 27 views

Hi ,

I am working on a requirement where a custom sling model needs to exclude pages that are unpublished/hidden from navigation, while recursively walking a page tree vis listchildren(). The issue driving this: page that are hidden in nav, unpublished and have a redirect configured still showing up in the list. so we need to explicitly hide unpublished pages, not just hidden ones. 

To fix this, I check cq:lastReplicationAction/cq:lastReplicationAction_Publish  on each pages’s ValueMap to filter unpublished ones. 

Resource contentResource = childPage.getContentResource();

            if (contentResource != null) {

                ValueMap properties = contentResource.getValueMap();

                isHidden = properties.get("hideInNav", false);

                isPublished = properties.get("cq:lastReplicationAction", String.class);

                 isPublishedDispatcher = properties.get("cq:lastReplicationAction_Publish", String.class);

            }



            if (isHidden || 

                (StringUtils.isBlank(isPublished) && StringUtils.isBlank(isPublishedDispatcher)) ||

                "Deactivate".equalsIgnoreCase(isPublished) || 

                "Deactivate".equalsIgnoreCase(isPublishedDispatcher)) {

                continue;

            }

 

  • Works on author
  • Works on local AEM SDK publish 
  • On Publish through dispatcher (no way to bypass it on AEMaaCS): component renders empty.  Properties confirmed present on Author. Still empty after a full pipeline deployment. 

Questions:

  1. Does this hld the same way on AEMaaCS publish?
  2. What is the right way to check “is the page published” from a sling mode on Publish/Dispatcher? 

    2 replies

    Level 4
    August 12, 2026

    Hi ​@SiddhiDa2,

    The issue is that cq:lastReplicationAction_Publish is written by the publish replication agent, but only on the Author instance, Publish never writes that property to itself. So when your model runs on Publish, isPublishedDispatcher is always blank, and your condition ends up being true for every page, which is why everything gets skipped.

     

    Instead of reading these replication properties by hand, I’d just adapt to ReplicationStatus, it handles the author/publish difference for you:

    ReplicationStatus repStatus = contentResource.adaptTo(ReplicationStatus.class);
    boolean isActivated = repStatus != null && repStatus.isActivated();

    if (isHidden || !isActivated) {
        continue;
    }
     

    That replaces both your isPublished/isPublishedDispatcher checks with one line that works the same way on both instances.

     

    To your questions - no, this won’t hold the same way on Publish, since that suffixed property simply isn’t there. And for checking “is this published” from a Sling model that runs on Publish/Dispatcher, ReplicationStatus is the way to go rather than reading the raw properties.

     

    One thing to watch for once you fix this: if you’re still seeing stale/incorrect results only when going through Dispatcher (but it’s fine hitting Publish directly), that’s a caching problem, not a code problem, Dispatcher won’t re-run your model on a cache hit, so you’d need a flush rule tied to activation for that page.

    SiddhiDa2Author
    Level 2
    August 12, 2026

    Thanks for the suggestion, I tried adaptTo(ReplicationStatus.class); too, but got same result, works on author but on publish through dispatcher while component renders empty, not just individual pages. Seems like whatever it relies on isn’t reliably available on publish either. Any other suggestions?