As a workaround, you could fetch the information before the user gets to your list view and store it in sessionStorage
...
Make the calls to find out if your user is in whatever groups you're trying to look at, then put the result in the sessionStorage
object with something like
sessionStorage.isInMySpecialGroup = "true" // sessionStorage only wants strings for values
or if you want to get fancier with multiple groups you could do
sessionStorage.spUserGroups = "Group1;Group2;Group3"
Then you can split the result on ";" if you want an array or something from it afterwards.
When you get to the CSR page, have your CSR script check sessionStorage for your values, I would recommend a default behavior too in case the user circumvents the page that should have loaded things (or you could get crafty and redirect them yourself to force the issue).
There are obviously some caveats here, the biggest of which is that it won't work on older browsers, so you should do something like feature detection before trying to access or write information there:
if (window.sessionStorage && window.sessionStorage.myData) {
//do stuff with your data
}
The other really big item is that it's your responsibility to make sure that your site behaves in such a way that the sessionStorage variable gets populated with your data before your users get to your CSR page that will rely upon the information (this can be harder than you might think... users tend to do whatever is convenient, not whatever will make your app work) -- and this is admittedly a tricky dependency to keep track of in an application.
Other things...
I noted in the first script example that sessionStorage
(and localStorage
for that matter) only accept strings for values -- so do something like JSON.stringify(...)
to store and JSON.Parse(...)
to read if you want to put objects in there.
sessionStorage
is only available on the page/tab that loaded the information into sessionStorage
and is deleted when you close the tab/browser.