AEM 65 - Sync Specific Folders to Scene7 in AEM Dynamic Media Scene7 (DMS7), Show Indicator in Card View


With AEM folder specific sync is available otb, for more information check documentation

By default, the Scene7 step of DAM Update Asset workflow syncs all assets uploaded to AEM, to Scene 7, in DMS7 mode (sling run mode dynamicmedia_scene7)

If the requirement is syncing specific folders, this post explains how-to, by adjusting the DAM Update Asset Workflow and show a UI indicator in card view (an improvement to the solution posted for 6420)

Another way of do this is by removing Scene7 step from default DAM Update Asset workflow, creating a DAM update workflow with Scene7 step having workflow launcher path condition set to e.g. /content/dam/my_dm_sync_folder(/.*/)renditions/original (where my_dm_sync_folder is the folder in AEM with assets synced to Scene7)

Demo | Package Install | Github

Set the Property "Sync to Scene7"

Property set and Saved in CRX

                           Once set, the checkbox is disabled, to avoid the mess of having some assets synced and others remain unsynced

UI Indicator "Uploads to Scene7"

Asset Uploaded to Scene 7

Managed locally in AEM


1) Login to CRXDE Lite, create folder (nt:folder) /apps/eaem-dms7-sync-specific-folders

2) Create clientlib (type cq:ClientLibraryFolder) /apps/eaem-dms7-sync-specific-folders/clientlib and set a property categories of String[] type to [cq.gui.damadmin.v2.foldershare.coral,dam.gui.admin.coral]dependencies of type String[] with value lodash

3) Create checkbox UI by adding the following code in /apps/eaem-dms7-sync-specific-folders/ui/syncToScene7 of type nt:unstructured

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="" xmlns:jcr="" xmlns:nt=""
    text="Sync to Scene7"

4) Create file ( type nt:file ) /apps/eaem-dms7-sync-specific-folders/clientlib/js.txt, add the following


5) Create file ( type nt:file ) /apps/eaem-dms7-sync-specific-folders/clientlib/add-sync-scene7-checkbox.js, add the following code

(function($, $document) {
    var FOLDER_SHARE_WIZARD = "/mnt/overlay/dam/gui/content/assets/v2/foldersharewizard.html",
        ASSETS_CONSOLE = "/assets.html",
        FOUNDATION_CONTENT_LOADED = "foundation-contentloaded",
        SEL_DAM_ADMIN_CHILD_PAGES = ".cq-damadmin-admin-childpages",
        LAYOUT_CARD_VIEW = "card",
        EAEM_SYNC_TO_SCENE7 = "eaemSyncToScene7",
        EAEM_UPLOAD_SCENE7_PROPERTY = "eaem-upload-scene7-property",
        SYNC_TO_SCENE7_CB = "/apps/eaem-dms7-sync-specific-folders/ui/syncToScene7.html",url = document.location.pathname, $customTab;

    if( url.indexOf(FOLDER_SHARE_WIZARD) == 0 ){
    }else if(url.indexOf(ASSETS_CONSOLE) == 0){
        $document.on("foundation-selections-change", SEL_DAM_ADMIN_CHILD_PAGES, showSyncUIIndicator);

    function handleFolderProperties(){
        $document.on(FOUNDATION_CONTENT_LOADED, function(){

    function showSyncUIIndicator(e){

        var $currentTarget = $(e.currentTarget),
            foundationLayout = $"foundation-layout");


        var layoutId = foundationLayout.layoutId;

        if(layoutId !== LAYOUT_CARD_VIEW){

        var path = $"foundation-collection-id");

        $.ajax(path + ".2.json").done(function(data){
            $(".foundation-collection-item").each(function(index, item){
                itemHandler(data, layoutId, $(item) );

        function itemHandler(data, layoutId, $item){
            var itemPath = $"foundation-collection-item-id"),
                itemName = getStringAfterLastSlash(itemPath);

            if( (layoutId !== LAYOUT_CARD_VIEW) || !_.isEmpty($item.find("." + EAEM_UPLOAD_SCENE7_PROPERTY))) {

            if(!data[itemName] || !data[itemName]["jcr:content"] || !data[itemName]["jcr:content"][EAEM_SYNC_TO_SCENE7]){

            var $cardProperties = $item.find("coral-card-content > coral-card-propertylist");

        function getScene7PropertyHtml(){
            return '<coral-card-property icon="upload" title="Uploads to Scene7" class="' + EAEM_UPLOAD_SCENE7_PROPERTY + '">' +
                        '<coral-card-property-content>Uploads to Scene7</coral-card-property-content>' +

        function getStringAfterLastSlash(str){
            if(!str || (str.indexOf("/") == -1)){
                return "";

            return str.substr(str.lastIndexOf("/") + 1);

    function addSyncScene7CheckBox(html){
        var $tabView = $("coral-tabview");


        var detailsTab = $tabView[0]._elements.panelStack.querySelector("coral-panel:first-child");


        var $cbSyncToScene7 = $(html).appendTo($(detailsTab).find(".aem-assets-foldershare-details-container")),
            $form = $("form"),
            $submit = $("button[type=submit]");

        $.ajax($form.attr("action") + "/jcr:content.json").done(setSyncScene7ContentCB);


        function setSyncScene7ContentCB(fJcrContent){
            var $cb = $cbSyncToScene7.find("[type='checkbox']"),
                name = $cb.attr("name");


            $cb[0].checked = true;

            $cbSyncToScene7.attr("disabled", "disabled");

        function handlerFolderPropertiesSubmit(){
            var $cb = $cbSyncToScene7.find("[type='checkbox']"),
                data = {};


            data[$cb.attr("name")] = $cb.val();

            $.post( $form.attr("action") + "/jcr:content", data );
})(jQuery, jQuery(document));

6) Edit the DAM Update Asset workflow (copy of /libs/settings/workflow/models/dam/update_asset created in /conf/global/settings/workflow/models/dam/update_asset) to add an OR Split step, move the Scene7 step to branch 1 and add a No Operation step in branch 2

7) Add the following script in branch 1 of OR Split; So the images and videos uploaded to folders with property eaemSyncToScene7 are ONLY synced to Scene7)

function check() {
    var doSync = false;
    try {
        var path = workflowData.getPayload().toString();
        if (path === null) {
            return doSync;
        path = path.replaceAll("/jcr:content/renditions/original", "");
"Checking if asset should be uploaded to Scene7 - " + path);
        var payloadNode = workflowSession.getSession().getNode(path);
        if (payloadNode === null) {
            return doSync;
        doSync = payloadNode.getParent().getNode("jcr:content").hasProperty("eaemSyncToScene7");
        if (doSync === false) {
  "Skipping upload to Scene7 - " + path);
        } else {
  "Uploading to Scene7 - " + path);
    } catch (e) {
        doSync = false;
    return doSync;

8) For the branch 2 (no operation) add the following script

function check(){
      return true;

9) Sync the workflow to copy the model from /conf/global/settings/workflow/models/dam/update_asset to /var/workflow/models/dam/update_asset

10) Upload an asset to folder with Scene7 sync allowed, you can see the jcr:content/metadata@dam:scene7ID  in asset metadata, confirming the upload to Scene7

11) Assets in folders that are skipped by OR-split do not have jcr:content/metadata@dam:scene7ID  in asset metadata and are not uploaded to Scene7

No comments:

Post a Comment