I installed Javascript Console 0.4.3 on my Alfresco 4.0a and got errors on the search.xpathSearch call that it uses to find any javascripts that should be included before executing the javascript typed into its text box.Researching the Alfresco documentation, the call seemed correct and is shown below.
var includeFolder = search.xpathSearch("/app:company_home/app:dictionary")[0].childByNamePath("Javascript Console Includes");
if (!includeFolder) {
logger.log("Creating new Javascript Console Includes folder");
var dictionary = search.xpathSearch("/app:company_home/app:dictionary")[0];
includeFolder = dictionary.createNode("Javascript Console Includes", "cm:folder", [], "cm:contains", "app:jsincludes");
}
By commenting this code out of the JavaScript Console script files I was able to run the Console and then try and execute an xpathSearch from within the Console itself. Even reproducing the xpathSearch call in the on-line documentation for xpathSearch in Alfresco 4.0 I got an error.Searching JIRA turned up ALF-10663 which is that if you selected xpath off the search type drop down list in the Node Browser you got an "Unknown language type" error but this is far from the same error as I got in Javascript Console and the suggestion in the JIRA is that this was because the option for xpath just needed removing from the drop down. The JIRA is marked as complete, but how or in which version of Alfresco it was completed is unclear and whether or not it caused a change in xpathSearch java code is not specified.I changed the search.xpathSearch to search.query using the fts-alfresco language as shown below and everything worked fine
var def =
{
query: 'PATH:"/app:company_home/app:dictionary"',
language: "fts-alfresco"
};
var results = search.query(def);
var includeFolder = results[0].childByNamePath("Javascript Console Includes");
if (!includeFolder) {
dictionary = results[0];
includeFolder = dictionary.createNode("Javascript Console Includes", "cm:folder", [], "cm:contains", "app:jsincludes");
}
I am making this log in case anyone else with 4.0a is experiencing difficulties with xpathSearch or Javascript Console and to ask whether or not there is a bug in 4.0a which affects xpathSearch which is subsequently fixed in 4.0b+ or if xpathSearch is actually no longer available or if the the syntax changed from that which is in the documentation.Thanks in advanceBob Johnson