Expand my Community achievements bar.

SOLVED

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

Avatar

Level 1

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@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

Avatar

Community Advisor

@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