AEM - Assets. Locking and unlocking an asset/page when more than one Editors are working on the same | Community
Skip to main content
February 20, 2023
Solved

AEM - Assets. Locking and unlocking an asset/page when more than one Editors are working on the same

  • February 20, 2023
  • 2 replies
  • 1919 views

Hi, 

I would like to know if there's a feature or - a way around - to avoid that more than one editors modify the same assets when being worked on.

As of now there's the manual option to Checkout an asset to lock it BUT when it is being worked on on an asset, the asset should be automatically locked so another editor cannot go in and overwrite the other’s work.

 

Also, when an asset is locked manually until published (scheduled publication) is there a way to unlock it automatically after the publication so that after can be edited by other editors?

 

Is there a way to achieve that?

 

Thank you so much in advance,

Tina

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SivakumarKanoori

@tina_iu :

 

I think , you can do it by writing javascript as below. when you click on edit option, this script will get invoked for checkout. Based on your use case you can restrict this to assets.

 

var z = $('.aem-assets-admin-actions-edit-activator');
var assetUrl = "/content/dam/test/abc.jpg.checkout.json"

z[0].onclick = function(){
$.ajax({
url: assetUrl,
type: "POST",
data: {action:'checkout'},
success: function(data){
// alert(data[message]);
},
error: function(data){
//alert("error!");
}
});

}

 

same way you can write a click event even on publish option to check in 

only change is that in ajax call , you can send the action as check in as below.

var x= $('.cq-damadmin-admin-actions-publish-activator');

x[0].onclick = function(){

$.ajax({
url: assetUrl,
type: "POST",
data: {action:'checkin'},
success: function(data){
// alert(data[message]);
},
error: function(data){
//alert("error!");
}

}

2 replies

SivakumarKanoori
Community Advisor
SivakumarKanooriCommunity AdvisorAccepted solution
Community Advisor
February 21, 2023

@tina_iu :

 

I think , you can do it by writing javascript as below. when you click on edit option, this script will get invoked for checkout. Based on your use case you can restrict this to assets.

 

var z = $('.aem-assets-admin-actions-edit-activator');
var assetUrl = "/content/dam/test/abc.jpg.checkout.json"

z[0].onclick = function(){
$.ajax({
url: assetUrl,
type: "POST",
data: {action:'checkout'},
success: function(data){
// alert(data[message]);
},
error: function(data){
//alert("error!");
}
});

}

 

same way you can write a click event even on publish option to check in 

only change is that in ajax call , you can send the action as check in as below.

var x= $('.cq-damadmin-admin-actions-publish-activator');

x[0].onclick = function(){

$.ajax({
url: assetUrl,
type: "POST",
data: {action:'checkin'},
success: function(data){
// alert(data[message]);
},
error: function(data){
//alert("error!");
}

}

Thanks,Siva
Manu_Mathew_
Community Advisor
Community Advisor
February 21, 2023

@tina_iu Probably you could create a custom workflow/ EventListeners that does that - by setting the `jcr:isCheckedOut` to true and false as per the actions