+ Start a Discussion
SFAshSFAsh 

Contact fields inaccessible

Hello,

 

We have been using the Salesforce API for some time now. Recently we have encountered an issue in accessing fields of an entity, Contact.

 

While reading the contact information we used to fetch the values of 'HomePhone' and 'OtherPhone' along with other fields. However now when we try to get contact information, it is throwing an error with following message.

 

No such column 'HomePhone' on entity 'Contact'. 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 problem it seems here is, those fields (HomePhone and OtherPhone) are made disabled rather inaccessible possibly through 'Set Field-Level Security' option of the field.


Is this correct behavior?

  • If NO, what should happen? 
  • If YES, how to tackle this issue?

Please advise me.

 

Thanks
Ashish

Best Answer chosen by Admin (Salesforce Developers) 
JayNicJayNic

You could try building a first call to describe the object, get all the fields on the object, then construct a query

 

I've never used the rest api, but this is the method you would need

http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_describe.htm

 

 

That way you will always get only what you're allowed to see. This does mean executing a second api request for each request. Maybe you can do this only if you get the exception and store the field values somewhere locally so you don't have to execute so many api calls. Just apply the precise amount of pressure needed

All Answers

Sri549Sri549

Hi

This is the correcct syntax for resolving the issue of No such column HomePhone

 

 <apex:inputField value="{!Contact.HomePhone}"/>
 <apex:inputField value="{!Contact.OtherPhone}"/>

 

Thanks

Srinivas

AschaeferAschaefer

you're on the right track: just make sure the Field-Level Security is set to "Editable" or at least "Visible" for the profile of your API only user.

 

And yes, this is correct behaviour: if the field is set to "Hidden" for a certain profile, the system behaves as if the field wouldn't exist.

 

Cheers,

Andreas

 

SFAshSFAsh

Hi Srinivas,

 

We are consuming Salesforce API through RESTful web services of microsoft .net. I am not sure how to use your piece of code to resolve the issue?

 

Thanks

Ashish

 

SFAshSFAsh

Hi Andreas,

 

If this is the behaviour of Salesforce (if requested fields are visible, they will be returned else exception will be thrown), is there no way for my code to work irrespective of fields are enable (visible) or not?

 

Is it possible for me to get the set of fields which are enabled before I request for Contact details? This will help me to form my query to get Contact details.

 

Thanks

Ashish

sandeep@Salesforcesandeep@Salesforce

You have to give field level permission ( view and Edit) on profile of user by which you are logged in.
Goto
Profile - Edit-> standard field permission - > Contact - > view fields -> change permission

Second way go to field directly and click on Edit accessibility

JayNicJayNic

You could try building a first call to describe the object, get all the fields on the object, then construct a query

 

I've never used the rest api, but this is the method you would need

http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_describe.htm

 

 

That way you will always get only what you're allowed to see. This does mean executing a second api request for each request. Maybe you can do this only if you get the exception and store the field values somewhere locally so you don't have to execute so many api calls. Just apply the precise amount of pressure needed

This was selected as the best answer
SFAshSFAsh

Hi JayNic,

 

Thanks for the reply.

 

I tried with the sample given in the link you provided to get available fields for Account object,

https://na1.salesforce.com/services/data/v20.0/Account/describe

 

But however the above url did'nt work straight away, instead I used the below url with small change and it worked fine.

To get avaialable fields for Account object use the below url.

 

https://na1.salesforce.com/services/data/v20.0/sobjects/Account/describe.

 

The soojects was missing in the sample in the sample.

Thanks for your help.

It worked after the change.

 

Thanks

Ashish