0

I'm doing API requests via the PHP library (https://github.com/phpforce/soap-client), and I'm using the enterprise WSDL.

Everything is working fine, but with one exception - some of the fields are not being returned via the API. Its not like they are null; instead they have been completely omitted. These are all new fields that have been added in Salesforce recently. Older fields (that have been there for a while) all return correctly.

The fields have definitely been spelled correctly, because if I make an intentional typo, then the API throws an error. So the fields definitely exist in Salesforce, but they just are not returned at all in the API.

Is there some kind of permissions that need to be set up in Salesforce, or something else that we are missing?

I've made sure to run the following script

ini_set("soap.wsdl_cache_enabled", "0");

Thanks for the help!

Edit I've just tried returning all fields for the object:

$objects = $client->describeSObjects(['Account']);

foreach ($objects as $object)
{
    foreach($object->getFields() as $key => $field)
    {
        print_r($field->getName() . PHP_EOL);
    }
}

And I can clearly see the new fields ARE there. I confirm that the WSDL was definitely created after the new fields were created, and if I examine that WSDL, the new fields are indeed listed.

Unfortunately I can't use the Partner WSDL, because the library doesn't support it :(

  • @Eric please see Edit above – JonoB Sep 6 '17 at 14:43
  • @Eric can you please add this as an answer so I can give you credit. I was using a limit in the query, and of course it was just my luck that the fields returned were empty. – JonoB Sep 6 '17 at 21:52
  • Done........... – Eric Sep 6 '17 at 21:54
1

It is either a permissions issue or the WSDL was generated before the fields were present in the org.

Try using the partner wsdl and do a describe on the object and see if the fields come back

Also, are the fields populated with values on the record you are querying?

If the field is not populated it will not be returned

If they are not populated, then populate them and retry the query to see if they are now returned

  • This is the right answer! If the API returns data, and there is no data in the relevant fields, then those fields will not be returned via the API. How stupidly frustrating! – JonoB Sep 7 '17 at 9:42
3

In Salesforce you need to check that your API User has Read Access permission to the fields you are requesting.

Setup -> Profiles -> API User -> Field-Level Security

  • Yes, the api user has read only access to all fields in the relevant objects – JonoB Sep 6 '17 at 13:49

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.