function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
joaquin-timbajoaquin-timba 

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

 

<apex:smileytongue:age controller="TestProfileBug" >
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apex:smileytongue:age>

 

 

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

atormanatorman
We are enforcing read access to setup areas with the view setup and configuration permission.  What is your use case for using API users who do not have this permission on their profile already? Is there a blocking reason for giving this permission to your API User?
aalbertaalbert
I can't speak for joaquin-timba's use case, but in the past, I have seen the need for end-users to run scontrol and apex code to check which Profile they are. And that code or logic would only be applied for a set of Profiles. So even though the user can't manage their profile or any other Setup permissions, they need the ability to "see" the Profile fields in their code (scontrols, apex). 
atormanatorman
We're currently looking into why this happens.  In the meantime, please try using 'without sharing' in your apex class.
bdr_09bdr_09

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

jwolfjwolf
Was this issue ever resolved? I'm using without sharing and I'm still getting the same error message. It also looks like it is an uncaught exception on the salesforce side. I see a pretty large error message and stack trace where the exception is 'common.apex.runtime.impl.ExecutionException'