Skip to content

Instantly share code, notes, and snippets.

@loftux
Created September 11, 2013 12:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save loftux/6523137 to your computer and use it in GitHub Desktop.
Save loftux/6523137 to your computer and use it in GitHub Desktop.
Script to reset user dashboard in Alfresco. Actually two scripts in same Gist. To be used with the Alfresco Javascript console//
//***** Script variant one, fore one user ********
var userid = "userid01";
var searchobj = {
query:'PATH:"/app:company_home/st:sites/cm:surf-config/cm:components/*" AND @cm\:name:"*'+userid+'*"',
language: 'fts-alfresco'
};
var nodes = search.query(searchobj);
for(i=0, ii=nodes.length;i<ii;i++){
//use only the dashboard ones
if(nodes[i].name.indexOf('dashboard')>-1){
print(nodes[i].name);
//nodes[i].remove();
}
}
print('***')
searchobj.query = 'PATH:"/app:company_home/st:sites/cm:surf-config/cm:pages/cm:user/cm:'+userid+'/*"';
nodes = search.query(searchobj);
for(i=0, ii=nodes.length;i<ii;i++){
//use only the dashboard ones
if(nodes[i].name.indexOf('dashboard')>-1){
print(nodes[i].name);
//nodes[i].remove();
}
}
print(new Date().toString());
//***** Script variant two, fore all users dashboard ********
print('Deleting all user welcome dashboards');
var searchobj = {
query:'PATH:"/app:company_home/st:sites/cm:surf-config/cm:components/*" AND @cm\:name:"*dashboard*"',
language: 'fts-alfresco'
};
var nodes = search.query(searchobj);
for(i=0, ii=nodes.length;i<ii;i++){
//use only the dashboard ones
if(nodes[i].name.indexOf('user')>-1 && nodes[i].name.indexOf('width')>-1){
print(nodes[i].name);
//nodes[i].remove();
}
}
print(new Date().toString());
print('Finished');
@loftux
Copy link
Author

loftux commented Sep 11, 2013

nodes[i].remove(); is commented out above, this way you can do a dry run. Remove comment to actually remove dashboard components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment