+ Start a Discussion
adrienadrien 

INVALID_FIELD: ProfileId????

We have an application that runs in a web tab and for this one specific user we are getting this error when they click on the tab.

INVALID_FIELD: SELECT ProfileId FROM User WHERE Id = '123456ABCDEFG' ^ ERROR at Row:1:Column:8 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.

Note: I have masked the Id, we are using a real Id not 123456ABCDEFG

I believe but cannot confirm that it is because the user does not have permission to "View Setup and Configuration"... any ideas?

Cheers!

SuperfellSuperfell
That's correct.
gregsgregs

So if a user has a profile that does NOT have "View Setup and Configuration" checked and tries to access the profileId field for the current user info by doing a select profileId from user where Id='thecurrentusersid' and they get the following error:

 

Description : "INVALID_FIELD:
SELECT ProfileId FROM User
       ^
ERROR at Row:1:Column:8
No such column 'ProfileId' on entity 'User'. If you are attempting to use a custom field, be sure to....

 

Is there any workaround this problem?  We have an application that uses the office toolkit as one of the components and there is currently not a profileId field available for the current session info, so we are forced to select it from the user table where the user is the current user making the request.

Message Edited by gregs on 01-21-2009 04:55 PM
joaquin-timbajoaquin-timba

Hi, we have had similar issues. It seems that in Spring 09 release this changed had been introduced. 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:page controller="TestProfileBug" >
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apex:page>

 

 

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

SuperfellSuperfell
You'll probably get better luck asking on the VF forum. However if you're seeing a change in behavior between releases, please log a support case.