5

We have noticed that Developer Console does some kind of an update on the current user's User record. When that happens, our User trigger is invoked, but with what seems limited permissions, and we get an exception emailed to us from Salesforce saying the following:

"No such column 'FirstName' 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."

The error references a line with the simple query:

List<User> lookup = [select FirstName, LastName, Region__c, UserPreferencesApexPagesDeveloperMode from User where Id =: userId limit 1];

How weird is that? We haven't pinpointed exact action in the developer console that causes this.

1 Answer 1

3

The developer console creates and manages IDEWorkspaces to keep track of open files, exec anon scrips, queries, etc. There is a field on User called "workspaceId" which is only exposed in the Tooling API. This field is used to keep track of the users current workspace. When you open the developer console for the first time or when you switch to a different workspace, the developer console updates the workspaceId field on user.

Triggers and validation rules shouldn't be fired if that is the only field being updated because it is a tooling only field. The fact that yours is being fired is a bug. I would file a case with Salesforce.

The reason why you are getting the query exception, is because only a few fields are exposed in tooling. If any other fields are queried for inside of a tooling API context, i.e. your trigger fired by a tooling API update, you will get an error like that. One way to see the exposed fields in tooling is to look at your tooling.wsdl by going to Setup -> Develop -> API -> Generate Tooling WSDL.

<xsd:complexType name="User">
    <xsd:complexContent>
        <xsd:extension base="tns:sObject">
            <xsd:sequence>
                <xsd:element name="DelegatedUsers" minOccurs="0" type="tns:QueryResult" nillable="true"/>
                <xsd:element name="ManagedUsers" minOccurs="0" type="tns:QueryResult" nillable="true"/>
                <xsd:element name="UserPreferences" minOccurs="0" type="tns:QueryResult" nillable="true"/>
                <xsd:element name="WorkspaceId" minOccurs="0" type="tns:ID" nillable="true"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>
3
  • Thank you. This org is at the old buggy summer 14 release, which hasn't been fixed yet, so possibly it will be fixed with the new release coming out this/next week. Jul 18, 2014 at 16:31
  • Is there a way in our trigger to detect that the tooling API is executing it? Jul 18, 2014 at 18:37
  • Little late response, but no, I don't think there is.
    – Thomas
    Sep 9, 2014 at 4:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .