I have an SP web with many reports (lists) in about 30 categories (libraries, soon to be databases), and the report lists have many custom columns, about 100 different ones across 150 reports.

I can add each column as a metadata property, run the indexes and collect the data, that part is behaving. I can search against the columns, so that's working.

The challenge is building an advanced search page. Each report has different custom columns against which I can search. I don't want to list all 100 potential properties in the advanced search dropdown, they'll never find anything.

The desire is to add the properties dynamically. Say report one has columns run date, ID and location, and report 2 has ID, location, start date and end date. I want to add the properties based on which report is pulled up, so they can search easily on each report's data.

The most obvious issue is that the advanced search web page is sealed, so I can't get to the engine, or at least not easily. The second is I'm not sure how to get to the XML that holds the property info, or if I have to try adding something later on in the process to add the objects to the generated dropdown.

Now if the solution is to build my own advanced search page, that's going to be a bear, so the backup question is can anyone recommend a good one that would give me the functionality I need?

I've got to assume I'm not the only one to see this as a need, the hope is that someone else has come up with a way to do it.

  • how about creating refinable managed properties and use search refiners in the search page?
    – Manu
    Commented Jan 20, 2015 at 16:36
  • That looks to be something only in 2013? I'm stuck using 2010. Commented Jan 22, 2015 at 19:08
  • Search refiners and managed metadata is possible in SP 2010 as well, the following link may guide you better: cann0nf0dder.wordpress.com/2013/04/07/…
    – Manu
    Commented Jan 23, 2015 at 11:59

1 Answer 1


I appear to have solved the issue on my own.

The page generates a lot of javascript to build the form on the client side. This includes a series of arrays that contain the values for the property dropdowns, the order they should appear, and what type the columns are. The definitions start up around line 85 in the final page.

The arrays in question are:

  • arrPropNames
  • arrPropDispNames
  • arrResTypePropMap
  • arrPropDTs

I rewrote my webpart to kick out new versions of those arrays. Since they appear in the page later than the initial definitions, the new ones override the old ones.

    protected void Page_Load(object sender, EventArgs e)
        string theSubweb = Request.QueryString["category"];
        siteAddr = "http://" + Request.ServerVariables["SERVER_NAME"] + ":" + Request.ServerVariables["SERVER_PORT"] + "/";

        string nodeAddr = siteAddr + "/" + theSubweb; ;
        SPSite thesite = new SPSite(nodeAddr);
        SPWeb thisWeb = thesite.RootWeb;

        string thePath = Request.QueryString["path"];
        SPList theList = thisWeb.Lists[thePath];

        StringBuilder jsScript = new StringBuilder();
        jsScript.AppendLine("<script type=\"text/javascript\">");

        foreach (SPView theview in theList.Views)

            string thename = theview.Title;
            string theFields = "";
            if (thename == "All Documents")
                Lbl_COLDfields.Text = "";
                var ddlInd = 1;

                SPViewFieldCollection viewfieldCollection = theview.ViewFields;

                jsScript.AppendLine("var arrPropNames = [];");
                jsScript.AppendLine(" arrPropNames [0] = '(Pick Property)';");
                jsScript.AppendLine("var arrPropDispNames = [];");
                jsScript.AppendLine(" arrPropDispNames[0] = '\u0028Pick Property\u0029';");
                jsScript.AppendLine("var arrResTypePropMap  = [];");
                jsScript.AppendLine(" arrResTypePropMap[0] = [];");
                jsScript.AppendLine(" arrResTypePropMap[0][0] = 0;");
                jsScript.AppendLine("var arrPropDTs  = [];");
                jsScript.AppendLine(" arrPropDTs  [0] = 0;");
                //for (int i = 0; i < collStrings.Count; i++)
                foreach (string theFname in viewfieldCollection)

                    if (theFname != "DocIcon" && theFname != "LinkFilename" && theFname != "Modified" && theFname != "Editor" && theFname != "Report_Title")
                        string fNameNeat = theFname.Replace("_", " ");

                        theFields = theFields + fNameNeat + "<br/>";
                        jsScript.AppendLine(" arrPropNames[" + ddlInd + "] = '" + theFname + "';");
                        jsScript.AppendLine(" arrPropDispNames[" + ddlInd + "] = '" + fNameNeat + "';");
                        jsScript.AppendLine(" arrResTypePropMap[0][" + ddlInd + "] = '" + ddlInd + "';");

                        SPField columnDetails = theList.Fields[theFname];
                        string fieldType = columnDetails.Type.ToString();
                        string fieldTypenum = "";
                        switch (fieldType)
                            case "Text":
                                fieldTypenum = "0";
                            case "DateTime":
                                fieldTypenum = "3";
                                fieldTypenum = "0";

                        jsScript.AppendLine(" arrPropDTs[" + ddlInd + "] = '" + fieldTypenum + "';");
                        ddlInd = ddlInd + 1;
                Lbl_COLDfields.Text = theFields;

        litPropertyFix.Text = jsScript.ToString();


All the existing javascript uses the new values to generate the dropdowns and correctly updates the operand dropdowns.

My pages only use the text and datetime types, so those are the only ones I’ve included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.