0

This might be of use to someone. The client will access reports in a Sharepoint site solely through a custom search page, based around the OOTB advanced search engine. However, they wanted to be able to see all reports if they entered no parameters in the search page. The default, of course, is that you can't do that; you get the pop-up asking you to enter at least something.

Couldn't find a way to turn that off, so I added an amended version of the DoAdvancedSearch JavaScript function that updated the query. I'll add it in the Answer section so this comes up as answered.

0

Here's the amended function

function DoAdvancedSearch(queryParameterName, resultsPage, 
                      idOuterTable, idAndQueryTextBox, idPhraseQueryTextBox,
                      idOrQueryTextBox, idNotQueryTextBox, idPrefixScopeCheckBox,
                      idPrefixLangsCheckBox, idResultTypeList,
                      idPrefixPropNameSelect, idPrefixPropOperatorSelect,
                      idPrefixPropValueTextBox, idPrefixPropAndOrSelect) {

if (ValidateForm()) {
    var elements = findElements(idOuterTable, idAndQueryTextBox,
                                idPhraseQueryTextBox, idOrQueryTextBox,
                                idNotQueryTextBox, idPrefixScopeCheckBox,
                                idPrefixLangsCheckBox, idResultTypeList,
                                idPrefixPropNameSelect, idPrefixPropOperatorSelect,
                                idPrefixPropValueTextBox, idPrefixPropAndOrSelect);

    var query = ComposeQuery(elements);
    if (query != '') 
    {
        var url = resultsPage + '?' + queryParameterName + '=' + query;
        navigateTo(url);
    }
    else
    {
        query = '(Write%3E%3D1%2F1%2F2000%20AND%20isdocument%3Dtrue)';
        var url = resultsPage + '?' + queryParameterName + '=' + query;
        navigateTo(url);
    }
}
}

If the query isn't empty (some parameters were entered) it runs as normal. If not, it replaces the value with

query = '(Write%3E%3D1%2F1%2F2000%20AND%20isdocument%3Dtrue)';

Which is html-encoded cause it has to be - it checks for any item modified later than 1/1/2000, and is an actual document. I needed to add that cause when I ran without it, it displayed the sites "allpages.aspx" page, which they don't need to see.

Obviously that generic query can be customized any way you like, but I thought it'd be useful for someone in some bizarre circumstance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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