1

I am trying to generate apex class using Tooling API. In the apex class I am writing a query

[select Type, Origin, Count_of_Co_brand_card__c, CaseUser__r.City, IsEscalated, ClosedDate, SLAViolation__c, CreatedDate from Case where Id IN :recordIds]

using relationship field CaseUser__r.City

On creating the Apex class using Tooling API, I get exception in response as

"No such column 'City' 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.","errorCode":"INVALID_FIELD_FOR_INSERT_UPDATE","fields":[]

Here, When I create apex class manually consisting same query is saved successfully. Exception I am facing is through Tooling API. Any ideas?

  • 1
    The field City doesn't exist on the User object. Do you mean MailingCity (standard) or have you created a custom field called City but have forgot to include __c. – Dan Jones Nov 15 '16 at 8:34
  • 1
    @DanJones City is a valid field for User. I can run the following SOQL query via the API. Select Id, City from User – Daniel Ballinger Nov 15 '16 at 19:51
  • 1
    @DanielBallinger Interesting. You're correct, it must be something else! – Dan Jones Nov 16 '16 at 8:52
1

According to the docs, there are some Booleans that determine the City field's visibility.

UserPreferencesShowCityToExternalUsers

Type: boolean

Properties: Create, Filter, Update

Description: Indicates the visibility of the city field in the user’s contact information. City is visible only to internal members of the user’s organization when:

  • This field is false. When false, this field returns the value #N/A.

Additionally, there is also another Boolean:

UserPreferencesShowCityToGuestUsers

Type: boolean

Properties: Create, Filter, Update

Description: Indicates the visibility of the city field in the user’s contact information. When true, city is visible to guest users. Guest users can access public Site.com and Force.com sites, and public pages in Communities, via the Guest User license associated with each site or community. When false, this field returns the value #N/A.

I'd expect that, potentially, depending on how you're using the API and how you're logged into it, this would throw the error you're seeing in the Tooling API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.