Invalid Field error: No Such column on sobject (Salesforce Object)

|
| By Manju Kashyap

Invalid Field error: No Such column on sobject (Salesforce Object)
Description: While working on a feature to sync data in Salesforce using rest api in python, I got the following error:

Salesforce Object

And the problem was that the field already exist there in Salesforce and I have double checked it many times for the API name, I was using in the rest API, and it was also same. Even I had confirmed the field existence by running the query in the Salesforce Developer console and it was coming in the query too as shown below:

sf-object1

I have also checked through the Workbench query and Rest utility that the field exists.

Solution: Finally, after spending too much time and debugging the code deeply, I noticed that the actual issue was due to the Salesforce version used in the post URL of the Rest API:

sf-object2

Actually, this is the old version of Salesforce which was hardcoded in the code and now we were using the later version 56.0. That was the real reason for the error because some fields were added in the later version but did not exist in the older version. So by changing the version number in the URI, the problem had resolved.
Tip: one tip here is to use such settings/configurations (which may change in the future) in a constants file and use the constant variable where ever required instead of hardcoding it everywhere in the code if we are using that value at many places in the code.

Leave a Reply

Your email address will not be published. Required fields are marked *