+ Start a Discussion

How to LIMIT query when using a standardController?

So I've got this great little VF page that perfectly meets the needs of our users when embedded in the standard Account page layout. The problem is, it doesnt work for non-admin users.


It's basically just a data table generated from:


<apex:dataTable value="{!Account.ActivityHistories}" var="a" rows="5" columns="5" columnswidth="10%,10%,10%,10%,60%"  rules="rows" width="100%" bgcolor="#F3F3EC" cellpadding="3px" cellspacing="2px">



When the Account page is viewed by a non-admin user though, the page returns:


Content cannot be displayed: MALFORMED_QUERY: Implementation restriction: activity aggregate relationships only allow security evaluation for non-admin users when LIMIT is specified and at most 500

 Ok, seems pretty self explanatory, just need to limit the query. But how? I'm only asking for the 5 most recent. I'm really hoping I don't have to write an extension just for this.


Any thoughts?



Well, I got it working with an extension, but it would be nice if I could do without it.


I wonder if applying the limit is something that VF would do if you were rendering it with a pageBlockTable instead of within a dataTable? (Just because VF "knows" metadata within pageBlockTable) I agree that It does seem like something that should work out of the box. 


Curious if you run the experiment...   Best, Steve.


No go with the pageBlockTable either sadly.


Does anything change if you:


Setup -> Customize -> Accounts -> Account Owner Report and check the "Allow all users to run the Account Owner Report" box?


(For some reason your issue has really piqued my curiousity... :-)   )




Btw,  I'm almost certain that setting above won't do a thing... I'm just curious. 


When you run as a non-admin do your users have "View all" permission for Accounts?


Account Sharing is not private for us, so that option doesn't exist.


The user profile in question has "View All" for Accounts and Contacts.


I've got a case open with Dev Support, we'll see how that  goes.

Jonathan IJonathan I

Was there ever any resolution?


Just went back to look at my case with support.


Answer was "you must use an extension".


Unfortunate, yes?

Jonathan IJonathan I

Nice... Thanks for taking the time to check!


I just found in this post ( http://boards.developerforce.com/t5/Visualforce-Development/Implementation-restriction/td-p/200927 ) that removing the "with sharing" from the class description does resolve the issue for my users.


Yeah, that's still using an extension class though. If you just wanted to use a VF page with the standard controller, it seems you'd be SOL.