Adding a filter to an asp custom list page

SUGGESTED

Good morning all,

I'm trying to create a custom page to display a list with filter box. However, I cannot get this working. I've checked the following posts:
https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2009/10/29/building-list-screens-with-filterboxes.aspx
https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2009/07/29/building-list-screens-with-filterboxes-take-2.aspx

...and various other pages.

These have useful tips but reference v6.2 which and so appear to be quite out of date.
Also, they seem to start with the method from Sage, this is generally questioned in the comments, or in these posts changed by someone else at Sage. The posts seem to end with unanswered questions and a dead end.

I've tried many different ways now to get a filter box working on a custom asp page, all based on these posts but still cannot get the filter to work. So my question is...

1. Can this work?

2. Is there any confirmed code that will highlight how this should be done?

  • 0

    When you say the filter doesn't work, is it that it is on the screen but when you add and filter, it doesn't do what you wanted?

    One thing I found is the code:

    if (String(Request.Form(myE.item()))!='undefined')

    {

    strArg+=" and "+myE.item()+" like '"+Request.Form(myE.item())+"%'";

    }

    It builds a string in the WHERE clause of the SQL that is always using LIKE, which is not always what you require.

    I had to build logic into the code based on the field in question as it looped and built a relevant clause.

  • 0

    Thanks for the reply. This is certainly a problem I've run into and I'll check my code.

    I guess adding my code to this article would help!

    My feeling was that this is a pretty common problem and so it would be useful if the forum get a single working example off it. The suggestion from Jeff (in the article I mentioned) seems to have been questioned and altered by other people at Sage which I found a bit disconcerting.

  • 0

    Hello - my code is below.

    My main questio still stands - Has anyone had this working properly? I wouldn't want to think I'm wasting my time on something which isn't possible.

    This takes the built in OpportunityList block and my own custom filter block. (Filters on oppo_stage and oppo_status only).

    I've added a tab to the company screen and call the asp page from there and so I expect to be able to pick up the company id.

    The screen appears with list and filter.

    However, there are a few issues I'm stuck will

    1. The dropdowns in the filters for status and stage don't contain an --All-- option.

    2. The I click on the filter button, the list is filtered but the filter settings revert back to their previous setting. (e.g. initally the stage is 'in progress' (because its the first option in the list), if I change to 'Won' and click filter, only 'Won' oppos are display but the stage filter settings changes back to 'In Progress'

    3. When open the page from the Company screen using the tab I've created, the filter are not applied, they only get applied when I click on the filter button (this would be fine if I could get the filter options to display the --All-- value and default to that.

    You may wonder why I've create a list of opportunities on the company screen when one already exists?

    It's just an example, the simplest example I could think of - I wanted to avoid any further complication with custom entities.

    <%

    //GET THE COMPANY ID

    CurrentCompanyID=CRM.GetContextInfo("company", "comp_CompanyId");

    var sURL=new String( Request.ServerVariables("URL")() + "?" + Request.QueryString );

    List=CRM.GetBlock("OpportunityList");

    List.prevURL=sURL;

    container = CRM.GetBlock('container');

    container.AddBlock(List);

    //CREATE BLOCK AND BUTTON

    var FilterBoxBlock = CRM.GetBlock("CustomOpportunityFilterBox");

    var strFilterButton = CRM.Button("Filter", "filter.gif", "javascript:document.EntryForm.submit();");

    //ADD FILTER IN THE SCREEN AS BLOCK

    with (FilterBoxBlock)

    {

    NewLine = false;

    ButtonLocation = Bottom;

    ButtonAlignment = Left;

    Mode=Edit;

    DisplayButton(Button_Default)=false;

    AddButton(strFilterButton);

    }

    container.AddBlock(FilterBoxBlock);

    //BUILD UP THE ARGUMENT FOR THE SQL STATEMENT

    var strArg="oppo_primarycompanyid="+CurrentCompanyID;

    var myE = new Enumerator(FilterBoxBlock);

    while (!myE.atEnd())

    {

    myEntryBlock = myE.item();

    if (String(Request.Form(myE.item()))!='undefined')

    {

    strArg+=" and "+myE.item()+" like '"+Request.Form(myE.item())+"%'";

    }

    myEntryBlock.NewLine = true;

    myEntryBlock.AllowBlank = false;

    myE.moveNext();

    }

    //VIEW SQL WHERE STATEMENT ON SCREEN

    Response.Write(strArg);

    container.DisplayButton(Button_Default) = false;

    CRM.AddContent(container.Execute(strArg));

    Response.Write(CRM.GetPage('company'));

    %>

  • 0

    Yeah, I have got it working fine, I just had to do what I described in my last post.

    In what way is it not working?

  • 0

    1. The dropdowns in the filters for status and stage don't contain an --All-- option.

    2. The I click on the filter button, the list is filtered but the filter settings revert back to their previous setting. (e.g. initally the stage is 'in progress' (because its the first option in the list), if I change to 'Won' and click filter, only 'Won' oppos are display but the stage filter settings changes back to 'In Progress'

    3. When open the page from the Company screen using the tab I've created, the filter are not applied, they only get applied when I click on the filter button (this would be fine if I could get the filter options to display the --All-- value and default to that.

  • 0 in reply to S Ward
    SUGGESTED

    Please check with the screen you created, if the type is 'Entry Screen', it will not show '--All--' Option.