Hello,
I have a situation where I need to have caching enabled in SSRS reports. It's mandatory since without it the reports take like 40 minutes to run. However, it's also mandatory that I filter the reports' content based on the User that is executing them.
I've been researching about this issue and I haven't found any workaround that allows making references to User!UserID and cache the report. Apparently, it's like that by design, as explained in the following thread:
https://social.msdn.microsoft.com/Forums/en-US/61bcc226-7188-4187-86e6-286c113bbc17/action?threadDisplayName=sqlserver&forum=sqlreportingservices
However, I still don't understand why it doesn't allow caching if the User!UserID is not used as dataset's parameter.
I have tested and I can indeed make references to User!UserID in a label inside of the report and it's read from cache. I have double checked this against SSRS's database "ExecutionLogStorage". I can see there that the report is indeed being read
from cache.
Hence, it's not the reference itself what causes the cache invalidation, it's where I use it. I know I can't use it as dataset's parameter, but I've tried using it as dataset's filter instead. It still causes the invalidation.
I have custom code in order to get the UserID, and I make a call in an expression in a dataset's filter. The code is as follows:
Public Function UserName()
Try
Return Report.User!UserID
Catch
Return "System"
End Try
End Function
Even with that, it still causes the cache invalidation. I have tried with and without code, I can't make it work.
I really need to filter the dataset's content based on the user. The dataset is used to show the available options in one of the report's parameters.
Is there any workaround to make the filter by User!UserID work, without causing cache invalidation.
Any help will be appreciated, any idea. I really need to make it work, this report without caching can't work. And it needs to be secured.
Thank you!