Customer Portal

Get Involved. Join the Conversation.

Topic

    Patricia Harvath
    Passing 'p' with the ProductCategoryInput widget.Answered
    Topic posted December 28, 2011 by Patricia HarvathBronze Medal: 1,250+ Points, last edited January 17, 2012 
    1771 Views, 27 Comments
    Title:
    Passing 'p' with the ProductCategoryInput widget.
    Content:

    Hi,

    I am trying something that should be easy.  On the home page, we would like users to select a product and on submission, be redirected to the ask page with the product pre-selected.

    So, I am trying to pass the selected product from the ProductCategoryInput widget from the home page to the ask page using add_params_to_url in the FormSubmit widget. When I hit the submit button, I am redirected to the ask page, but the 'p' param is not added to the URL. What am I missing?

    We're using Nov '10.

    Thanks.

    Code Snippet:

    Best Comment

    Ernie Turner

    Ok, you should be able to do this using the ProductCategorySearchFilter widget. I'm not entirely sure if all of these attributes are available on your version or not, but adding this should work

        <rn:widget path="search/ProductCategorySearchFilter" search_on_select="true" report_page_url="/app/ask" show_confirm_button_in_dialog="true"/>

    This will display the dropdown and nothing else, and when the user selects an item, it will redirect to the ask page with the product parameter in the URL which should pre-populate the widget on the ask form.

    Comment

    • Patricia Harvath

      My mistake.  When the submit button is clicked, I get an error.  Does this widget have to be associated with a contact or incident to work?

      Thanks.

    • Ernie Turner

      Just so I understand what you're trying to do here, you want users to basically submit a form on the home page that will redirect them to the ask page? Have you looked into the search/ProductCategoryList widget at all? It will display a hierarchal list of either products/categories as links that you can point to the ask page. I think using that widget might be easier than using the treeview dropdown widget.

    • Patricia Harvath

      Yes, this is exactly what I want only in a drop down format.  How difficult is it to change the list to a drop down?

    • Ernie Turner

      Ok, you should be able to do this using the ProductCategorySearchFilter widget. I'm not entirely sure if all of these attributes are available on your version or not, but adding this should work

          <rn:widget path="search/ProductCategorySearchFilter" search_on_select="true" report_page_url="/app/ask" show_confirm_button_in_dialog="true"/>

      This will display the dropdown and nothing else, and when the user selects an item, it will redirect to the ask page with the product parameter in the URL which should pre-populate the widget on the ask form.

    • Patricia Harvath

      That works great, except there is a flash of an error on the home page before the redirect stating that the request could not be completed.  I am guessing this is from some of the other code on the page.  I am not sure how I would debug this.  Any quick suggestions?  

      Thanks!

    • Patricia Harvath

      I've removed everything from the page except the search/ProductCategorySearchFilter.  A message box with a Warning that the request could not be completed pops up for a sec and then redirects to the /app/ask page with the correct product selected in the input/ProductCategoryInput widget.

      Where can I disable this alert box?

      Thank you!

    • Ernie Turner

      I'm guessing there is an outstanding Ajax request being made to the server when the redirect takes place. You'll have to use something like Firebug or Fiddler to track what that request is. I can't think of any request that the ProductCategorySearchFilter would be making, but I could be wrong.

    • Patricia Harvath

      In Fiddler, once I select an option from the search/ProductCategorySearchFilter widget, there is an ajax call:  

      https://domainName.custhelp.com/ci/ajaxRequestMin/getHierValues/filter/products/lvl/2/id/4140/linking/0

       

      When I call that page my response is:

      {"0":[],"link_map":[]}  

       

      Any idea what that means?

    • Patricia Harvath

      Hey guys,

      Does anyone have any idea how to cancel this ajax call?  

       

      Thanks,

      Patricia
      Happy 2012! 

    • Ernie Turner

      Hmm, the situation you're seeing appears to be a bug in that widget. Does removing the 'show_confirm_button_in_dialog' attribute from the widget fix this issue?

    • Patricia Harvath

      No.  Removing the 'show_confirm_button_in_dialog' attribute doesn't get rid of the alert. 

      Since there seems to be a bug with this widget, do you have any suggestions to a work around for this?  Do you think if I tried to get this to work in traditional PHP using a ROQL call with a post to the ask page that I might be able to accomplish the same thing?

      Thanks!


    • Ernie Turner

      The best solution I can think of here would be to create a custom widget that wraps around the treeview widget, and uses the events it fires to redirect the user. First things first, create a custom widget with a view.php and logic.js files. In the view, you would have this:

      <rn:meta controller_path="standard/utils/Blank" js_path="custom/sample/SampleWidget"/>

      <rn:widget path="input/ProductCategoryInput" table="incidents" show_confirm_button_in_dialog="true"/>

      Then, in the logic file, we're going to listen to an event that the ProductCategoryInput widget fires to know when the user has selected an item. To do that, it would look like so:

      RightNow.Widget.SampleWidget = function(data, instanceID)
      {
          this.data = data;
          this.instanceID = instanceID;

          RightNow.Event.subscribe('evt_productCategorySelected', this._takeUserToAskPage, this);
      };
      RightNow.Widget.SampleWidget.prototype = {
          _takeUserToAskPage: function(type, data)
          {
              var productChain = data[0].data.hierChain.join(',');
              RightNow.Url.navigate('/app/ask/p/' + productChain);
          }
      };

      I tried this briefly and it appeard to work just fine, but you'll obviously want to run this through some tests before you deploy it out. I've written up a bug report for the other issue, sorry that you ran into that.

    • Patricia Harvath

      Hi,

      Thanks for responding and I appreciate your following up on this issue. 

      I created the custom widget, but after I select the item in the drop down, nothing happens. The dropdown doesn't even select the item.  The "No Value" item remains selected.

      Thanks again!
      Patricia

       

    • Ernie Turner

      Are there any JS errors being thrown that you can see?

    • Patricia Harvath

      Yes, it throws this error:

      data[0].data.hierChain is undefined