Customer Portal

Get Involved. Join the Conversation.


    Shiloh Madsen
    Answers/List and Reports: Filter passingAnswered
    Topic posted September 9, 2013 by Shiloh MadsenBronze Trophy: 5,000+ Points 
    1921 Views, 23 Comments
    Answers/List and Reports: Filter passing

    Sorry for what amounts to, essentially a fishing expedition, but I simply cannot find good documentation on what seems to be one of the more complicated aspects of CP functionality. I am working on a few widget extensions, one that presents a different form of product selector as a typeahead and I am having a headache of a time getting that to hook into the search answers life cycle. In addition to that, some other functionality I have coded surrounding primary product seems to actually be affecting my searches (primary product always gets filled in on a blank search) and I simply don't know why. 

    So basically what I am trying to understand is what actually happens when i click the search answers button. Where are the product, category and keyword filters being read from and how do I overrride those. Looking at the submit button itself was pretty nearly useless...its code is so minor that I know the heavy lifting is going on elsewhere. It seems that at some point work ends up at getReportData in ajaxRequest.php but there must be one or more stops in between. Would anyone out here have any more insight into what those extra stops are?

    Best Comment

    Patrick Walsh

    Hi Shiloh,

    The ProductCategorySearchFilter widget is probably what is modifying your search.  When you click the search button it is raising an event and all of the search aware widgets can feed in filters.  So the KeywordText widget is adding any keywords, the filters for product and category come from the ProductCategorySearchFilter widget, etc.  The KeywordText widget makes it easier to see what's going on here.  Here are the salient parts of the code from KeywordText:

    1. RightNow.Widgets.KeywordText = RightNow.SearchFilter.extend({

    We extend from the SearchFilter base.

    2. constructor: function() { ... this.searchSource().on("search", this._onGetFiltersRequest, this); ... }

    In the constructor, we register for the search event and call a handler, _onGetFiltersRequest.
    3. = this.Y.Lang.trim(this._textElement.get("value"));
            this._searchedOn =;
            return this._eo;
    Finally we setup some filters and return them in the _onGetFiltersRequest handler.  
    So knowing all of this, you should be able to either extend the product filter widget and modify it to do what you want or to create a widget that extends from RightNow.SearchFilter and to modify the filters when the search event is raised.
    Hope that helps!



    • Shiloh Madsen

      Looks like its not coming through on the getReportData call:


      1. filters:
    • luke davison

      It looks like your post got truncated. Do you mind re-posting?

    • Shiloh Madsen

      Not truncated...just ran off the screen. I formatted it a bit.

    • luke davison

      Hey Shiloh,

      It appears that the problem is with the "data" property. For the product filter it's [[]] and for the category filter it's [null]. You might need to use the JavaScript debugger to step through the _getFiltersRequest method you posted to see why it's setting the values like that. I would start by adding breakpoints on lines in that method that set Hopefully this will point you in the right direction.


    • Shiloh Madsen

      Thanks for making me look a bit more deeply! The problem seems to be from me reading the value in the typeahead field, but as the typeahead clears in page transition, it is no longer there for pagination on the results page. So now I should just have to find a way to repopulate that field with the search term and I'll probably be good to go. 

    • Shiloh Madsen

      Ok, so two steps forward, one step back. So I have further data, and it LOOKED like I fixed the get filters problem..but all new ones. So heres where I stand. I grabbed a headers from both the vanilla search and from my updated search:


      Looks like the product is generated just fine, however, when I do a follow up search it hangs with a new error in console: 
      "Cannot read propterty 'linkID' of undefined". I checked the header for this one and its identical, with just a different product. 
      Just for grins, I tried to hard code the product ids and I never see this error...but that could just be because my search terms aren't changing. 
      Starting to feel like every bug I squash releases a new one to track down. Any direction for THIS trouble?
    • Shiloh Madsen

      So I found a very hackish workaround but now I have this 'interesting' intermittent glitch. Sometimes when I search on a new product, the url changes from /app/answers/list to /euf/assets/themes/themename...and im not entirely certain why this substitution is happening. Any illumination on this would be fantastic. 

      For those interested in my "hack" to solve the linkid of undefined...this was clearly a js issue with the searchfilters class not getting the right data for the onReportResponse method...however, the URL did get the memo that my product id had changed. As a result, I just tossed in my own code on the widget onReportResponse function to do a location.reload();. This caused the page to refresh after the report came in, thus providing me with useful report data. Ajax response isn't working, but the page itself is. 

    • Jeremy Watson


      Is it possible that JavaScript has not finished loading before you try a new search?  When I've seen something similar to what you describe, it is often because I am performing an action before all of the framework and widget JS has loaded and executed.