0

On a SharePoint SearchResults page the core results webpart can be refined or filtered using the QueryString paramters 'r=' or 'a=' in the url. I am attempting to use the 'a=' parameter which works great for the fields 'format' and 'author' but I have no been able to get it to filter on Modified Date aka 'write' or on Site Url aka 'sitename'

Example:

 //queryString was "r=write%3D%22AQlQYXN0IFllYXIFd3JpdGUAFwFbMjAxMy0wNC0xMFQwMDowMDowMFo7XQ%3D%3D%22"
 //removing the urlEncoding %3D%22 you are left with the below value.
r="AQlQYXN0IFllYXIFd3JpdGUAFwFbMjAxMy0wNC0xMFQwMDowMDowMFo7XQ";

/*following decode written by http://stackoverflow.com/users/516910/broc-seib */
decodeBase64 = function(s) {
    var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;
    var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    for(i=0;i<64;i++){e[A.charAt(i)]=i;}
    for(x=0;x<L;x++){
        c=e[s.charAt(x)];b=(b<<6)+c;l+=6;
        while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));}
    }
    return r;
};
s2=decodeBase64(r);
alert(s2);

If you run the code above in your browser you will see the search was 'Past Year | write'. and it returned a few hundred results. How do I get this query to work using the 'a=' paramter ?

0

There was two issues, first I was always using the query format field="value" but that only matches exact values unlike field:"value", also depending the datatype not all values use quotes. Another issue is CustomFilters which mask the original value such as Past Year instead of passing -365..

For more on this visit the MSDN page which explains the syntax

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.