Hi Everyone
I'm looking for some guidance on how to enhance our AEM Assets implementation. We have a large number of assets under the /content/dam/xxx path, and it's becoming challenging to track their expiry dates effectively. My goal is to implement a visual indicator—either a flag or an icon—on each asset within the AEM Assets interface that would dynamically appear when an asset's expiry date is within a certain threshold.
Specifically, I want to achieve the following:
Any suggestions please
Thanks in advance
Views
Replies
Total Likes
Hi @Prashardan,
This sounds like a very useful feature to improve the management of assets within AEM Assets (You could add this into the Idea's section of the community), especially when dealing with expiration dates. Below, I could share a few possible ways to approach this, leveraging AEM’s capabilities such as custom metadata, workflow, and frontend modifications.
1. Add Expiry Date Metadata to Assets (if not already done)
Ensure each asset has an "expiry date" stored as metadata. If your assets don’t already have an expiry date, you can create a custom metadata field for it.
Method: You can add the expiryDate
metadata field using a custom workflow or through bulk editing in AEM Assets.
Type: This metadata can be added as a Date
field.
2. Custom Workflow to Update Expiry Status
You can create a custom workflow in AEM that periodically checks assets for their expiry dates. The workflow could trigger a custom metadata update that marks whether an asset is within the 5-day expiry window.
Steps:
Custom Workflow Process: Create a custom workflow process that runs periodically (e.g., daily) and checks the expiry dates of assets in the /content/dam/xxx
folder.
Update Metadata: If an asset’s expiry date is within the next 5 days, update the metadata or set a flag field (e.g., expiryStatus
) to "expiring" or similar.
Trigger the Workflow: You can either trigger the workflow manually or set up a scheduled job to run the workflow periodically.
3. Display a Visual Indicator in the AEM Assets Interface
You can implement a custom component or use AEM’s client-side customization to dynamically display a visual indicator (like a flag or icon) on the asset’s thumbnail when the expiryStatus
flag is set to "expiring".
Option 1: Using a Custom Overlay or Icon on Thumbnails
Client-side: A custom JavaScript or CSS overlay can be added to the AEM Assets interface to check the metadata for each asset and display a flag/icon if the expiryStatus
field is "expiring."
How to implement:
Custom JavaScript: Add custom JavaScript to AEM’s DAM interface (via a clientlib or custom frontend code).
Query Metadata: When assets are loaded in the AEM Assets UI, use the AEM API (or Asset Manager) to query each asset’s expiryStatus
.
Conditionally Show Icon: If the asset’s expiryStatus
is "expiring" (or if the expiry date is within 5 days), display an overlay icon or flag on the asset’s thumbnail.
Option 2: Using AEM Asset's Metadata: If you’re looking to keep it simple, you can also modify the asset’s metadata view in the AEM interface to show a visual flag or indicator based on the expiry date field.
This can be done using JCR Queries and custom JSP components to render a flag icon next to the asset’s metadata in the UI.
Hope that helps!
Views
Replies
Total Likes
Hi @Prashardan ,
Try below steps:
Calendar today = Calendar.getInstance();
Calendar expiryDate = ... // pulled from asset metadata
Calendar thresholdDate = Calendar.getInstance();
thresholdDate.add(Calendar.DAY_OF_YEAR, 5);
if (expiryDate != null && expiryDate.before(thresholdDate)) {
asset.getMetadata().put("expiryWarning", true);
} else {
asset.getMetadata().put("expiryWarning", false);
}
3. Customize the AEM Assets UI (Coral UI)
Use a ClientLib to inject JavaScript into the AEM Assets UI and show a flag/icon when expiryWarning == true.
Steps:
- Create a ClientLib under /apps with category: dam.gui.customassetview.
- In the JS:
- Hook into AEM’s assetView rendering.
- Check the expiryWarning field.
- If true, append an icon to the thumbnail (e.g., a warning or calendar icon).
Sample JS Snippet:
(function(document, $, Coral) {
$(document).on("foundation-contentloaded", function() {
$(".foundation-collection-item").each(function() {
const $item = $(this);
const metadata = $item.data("foundation-collection-item-meta");
if (metadata && metadata["expiryWarning"] === true) {
$item.append('<div class="expiry-flag"> Expiring Soon</div>');
}
});
});
})(document, Granite.$, Coral);
Style the .expiry-flag in your CSS (in the same ClientLib).
Note: Ensure your service user for the scheduled job has read/write access to /content/dam.
Regards,
Amit
Views
Replies
Total Likes
@Prashardan : Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Thanks for your reply. I have tried you suggested.
I have overlayed /libs/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp to /apps/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp
I have a dc:expiry in metadata and want to read this property and when date is >= currentdate I want show the flag/icon.
Currently I am able to show icon but unable to read dc:expiry in the /apps/dam/gui/coral/components/admin/contentrenderer/card/asset/propertyList.jsp
Kindly advise.
Views
Replies
Total Likes
Views
Likes
Replies