AnsweredAssumed Answered

Resetting user dashboards using web script

Question asked by cybertoast on Dec 2, 2009
Latest reply on Dec 2, 2009 by mikeh
I'm using the code in the User Configurable Dashboards wiki page, and running into a problem.

The code finds all the available users (using luceneSearch for cm:person), then traverses this list and resets the preferences for each user. The traversal works fine, but when it gets to ..

         if (["app:dashboard"] != null)

.. this always returns null. Even for a user who has customized their dashboard. So what happens is that nothing is ever cleared since Alfresco thinks that there is no dashboard preference set.

I set this up as follows:
1. Create resetdashboards.get.js, resetdashboards.get.desc.xml, resetdashboard.get.html.ftl as follows (in Data Dictionary > Web Scripts > org > alfresco > sample):

var people = search.luceneSearch("TYPE:cm\\:person");

var notes = [];

for each (p in people)


   logger.log("Found user: " +;

   notes.push("Found user " +;

   if (p.hasAspect("app:configurable"))


      var config = p.childAssocs["app:configurations"][0];

      var prefs = config.childrenByXPath("app:preferences");

      if (prefs.length == 1)


         var preferences = prefs[0];

         if (["app:dashboard"] != null)


  ["app:dashboard"] = null;


            logger.log(" preferences found and cleared.");

            notes.push("Cleared dashboard for " +;






    <title>Reset Dashboards</title>
    <p> If everything worked users' dashboards should be reset to default. <a href="/share">Check yours out</a>.</p>
<#list notes as note>

<shortname>Reset User Dashboards</shortname>
<description>Revert all user dashboards to preset-based default</description>

I ran this using the alfresco javascript debugger, and I can see as I step through the code that I never get anything other than null for["app:dashboard"]. I'm running this is as the admin user.

Any ideas on what I might be doing wrong?