You need to sign in to do that
Don't have an account?
Spring 09 Bug - No such column ProfileId
Hi, we have had with the new realease "Spring 09" some issues. It seems that in Spring 09 release a changed had been introduced in profile permission. You can't anymore query any field from Profile object if you had not set "view setup and configuration permission" in the profile of the user running the application.
This is the test I made, and here the code:
-Controller
public class TestProfileBug {
public TestProfileBug()
{
User u = [Select Id, Profile.Name from User limit 1];
}
}
-Page
<apexage controller="TestProfileBug" >
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apexage>
Here we go with test result.
With a profile without "view setup and configuration permission"
This error appears:
"No such column 'ProfileId' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."
With a profile with "view setup and configuration permission" shows the page correctly.
My code doens't have any ProfileId, but internal salesforce's framework query this field to get the profile name.
Other thing is that if I save my controller and then log-in with a profile that don't have this permission all work great the first time. Then, I reload the page and the previous error appears.
I tried other ways to get profile name without any success. I think that this is the expected behavior, but it has to be a way that my code running under profile without this permission can query this object. I tried with System.RunAs(user) but as in previous release it seems not to be working in classes only with unit testing.
Any help about that will be appreciated. If possible, we would like to keep this permision away for almost all profiles for security reasons.
Thanks.
Joaquin
HI,
Just try to use like User u = [Select Id, Profile.name from User limit 1];
i.e; instead of Profile.Name replace with Profile.name.
Thanks,
--bdr_09