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
scoopscoop 

Api queries vs. Page layout

Hi,

We are having inconsistent problems with doing queries against fields that are not in a page layout.  Sometimes it works fine, other times an error occurs.  Do fields have do be in a page layout to be accessed through the api?  What is the relationship?

Thanks. 

benjasikbenjasik
There should be no need for fields to be in a page layout to query those fields. Field level security dictates api security.

Can you provide more information about the error you are receiving?
scoopscoop

I sent this

{sf:queryString}select Id, Name, Description, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry, Phone, Sic, AnnualRevenue, NumberOfEmployees, TickerSymbol, DUNS_Number__c, Parent_DUNS_Number__c, CC_Custom__c, ParentId, LastModifiedDate from Account where Id = '001000000033kx4'{/sf:queryString}

and got this error

{soapenv:Fault}

{faultcode}soapenv:Server{/faultcode}

{faultstring}INVALID_FIELD: Bad field name 'phone' in select list of query call

{/faultstring}

{detail}

{sf:fault xmlns:sf=`urn:fault.partner.soap.sforce.com` xsi:type=`sf:InvalidFieldFault`}

{sf:exceptionCode}INVALID_FIELD{/sf:exceptionCode}

{sf:exceptionMessage}Bad field name 'phone' in select list of query call

{/sf:exceptionMessage}

{/sf:fault}

{/detail}

{/soapenv:Fault}

When the field "phone" was added to the page payout, the query then worked fine.  This happens in some instances and not in others.  If I do the exact same thing to my developer instance it works fine.  FYI, the instance that threw the error was PE was the api turned on.