cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced search in dashlet using Document Library page

frontman
Champ in-the-making
Champ in-the-making
Hi everyone…

What I'm trying to accomplish is getting an advanced search in a dashlet. Looking in the web, I found this: http://loftux.se/en/2010/02/25/advanced-search-in-alfresco-share/.

Like you see, the solution is really simple: create a form with the fields you need, concat the values from those fields and get a url like this: /documentlibrary?filter=customQuery&filterData=file_whitepaper|doctype_contract. I was on 3.2 version and everything worked fine, but we migrated to 3.2r  and it doesn't work anymore.

I've doing some logging in doclist.get.js, filters.lib.js and parse-args.lib.js, which are the ones involved in processing the url.

case "category":
            // Remove any trailing "/" character
            if (filterData.charAt(filterData.length - 1) == "/")
            {
               filterData = filterData.slice(0, -1);
            }
            filterParams.query = "+PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\"";
            break;

      //Código para la búsqueda avanzada en Share
         case "customQuery":
      
      var filterDoctype = " AND(";
      var filterDoctypeCount = 0;

   logger.log("Custom query");

            filterQuery = "+PATH:\"" + parsedArgs.rootNode.qnamePath + "//*\"";

   logger.log("args.fliterData length: " +args.filterData.length);
            if(args.filterData.length > 0)
            {
                 var strData=decodeURI(args.filterData);
                 logger.log("cadena de busqueda:" + strData);
                 var queryArray=strData.split("|");
         logger.log("longitud arreglo:" + queryArray.length);
                 for(var i=0;i < queryArray.length;i++)
                 {
                    var strQuery=queryArray[i];
                    var strQueryArray=strQuery.split("_");
                    logger.log("elemento 0:" + strQueryArray[0]);
                    logger.log("elemento 1:"  + strQueryArray[1]);
                    switch (strQueryArray[0])
                    {

In filters.lib.js, in the switch part, it gets to "customQuery", but when it comes to if(args.filterData.length > 0), throws this exception: Cannot read property "length" from null.

Like I said, this was working on 3.2 and args.filterData contains the parameters that I put into the url but in 3.2r is alway null. The only difference I realized is the way document library page is called to show other option like "all", "editingMe", "editingOthers", etc.. Instead of /documentlibrary?filter is /documentlibrary#filter…what make me think that maybe I'm sending a malformed url and that's why I'm getting always null.

I really need help with this…thanks in advanced.
7 REPLIES 7

frontman
Champ in-the-making
Champ in-the-making
Mmmm…¿no one knows anything? ¿even an alfresco engineer can't help me?  Smiley Sad

loftux
Star Contributor
Star Contributor
Hi,

If you log the filterData, do you get any passed parameters?
In row 53 the filterData is cast into a string variable
var filterData = String(args.filterData)
Maybe better to use this variable (I dont know why I didn't).
if(filterData.length > 0)
Also output to the log file what the filterData variable contains.

frontman
Champ in-the-making
Champ in-the-making
I already found the solution.

Instead of '&', it must be "#" to identify the url parameters. (e.g. documentlibrary#filter=myQuery#filterData=file_myFile|doctype_myType)

Thanks for reply, loftux.

loftux
Star Contributor
Star Contributor
frontman,
I now need your help. I'm trying to get this to work on 3.2r Enterprise, and just cannot get filterData to be picked up. Have tried your suggestion for the url, but didn't help.
What version are you running? Can you post a complete working url? Any other changes you had to do?

frontman
Champ in-the-making
Champ in-the-making
Loftux, for some reason that solution worked fine at that time (I was working with a 3.2r development enviroment), but I tried in a new production enviroment with 3.2r and it's not working. Honestly I don't know what to do.

loftux
Star Contributor
Star Contributor
I have since my post figured it out. Vertical bar is now filterData delimiter, i.e
documentlibrary#filter=myQuery|mydatatobeusedinsearch
Since in my original solution I had | as a delimiter in the query it may have partially worked for you. If you replace that with something else so you get something like
documentlibrary#filter=myQuery|file:myFile_doctype:myType
I think it should work with this.

You can if you enable debugging in share-config-custom.xml, and then in the Share webclient hit ctrl+ctrl+shift+shift see debug output and that it picks up your filterData

frontman
Champ in-the-making
Champ in-the-making
Loftux…..thank you very, very, very, very,very much. I don't know how you figured it out but it works perfect. Thanks again.