In a SharePoint Online environment, I have a set of pages, each with a single page filter to drive 4 list/library web part views. I want to retrieve the value of that page filter and use it in some Content Editor Web Parts on the page.
The page filter is the value of a Business Function, with some options being Finance, Marketing, HR. The library views include Meeting Documents, Key Documents, and others. So one page would be Meeting Docs, Key Docs, etc., for Marketing. Another page would be Meeting Docs, Key Docs, etc., for HR. Above each list/library view, I want to have nicely-formatted headings like "Meeting Documents for Finance" and "Key Documents for Finance."
I have ~20 of these pages and want to keep maintenance to a minimum, which is why I'd like to retrieve the page filter and have it dynamically populate the headings.
I've tried following the example provided in this post: How to get value of List Filter web part in Javascript?, but do not have enough knowledge to put it all together.
Here is what I have in a script editor web part so far:
<script src="/sites/company/Scripts/jquery-1.6.4.min.js"></script>
<script src="/sites/company/Scripts/jquery.SPServices-0.7.1a.min.js"></script>
<script>
function getListFilterValueFromContextInfo(){
var filterFields = ctx.overrideFilterQstring.split('&');
var filterFunction = filterFields[1].split('=')[1];
return filterFunction;
}
ExecuteOrDelayUntilScriptLoaded( getListFilterValueFromContextInfo, "sp.js" );
var functionName=filterFunction;
alert(functionName);
</script>
I know I have a problem with global/local variables, but I can only ever seem to get the script to post an "alert" from within the function, or document.write outside the function, but without a value.
Thanks in advance for any direction!
ctx.overrideFilterQstring;
to make sure the required information (in your case its heading) are there. Can you post that in your answer?