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
Bharath Kumar ThotaBharath Kumar Thota 

How to get the field API names for the fields present in Report record

Hi,
I am using REST API to the whole information of a "Report" record in that I am able to see what filters are used and getting those values using Apex. But the problem I have is with "Standard Fields", the API names for the standard fields of an object are not same in the report record. I will explain with the below image:
User-added image
In the above image, [Item 2] and [Item 4] are custom field which doesn't trouble me. But the other 4 which I have highlighted are standard fields of Opportunity object. So these names doesn't match with either the label or API name of the field.
Example: [Item 6]
-> In this metadata name is OPP_QUANTITY
-> In Opportunity the label is Qunatity
-> In Opportunity the API name is TotalOpportunityQuantity
The name in this doesn't match with label or API name.
So how to retrieve the API name or label of that field is there any way.
Please help me with this.

Thanks,
Bharath Kumar Thota
Best Answer chosen by Bharath Kumar Thota
AnudeepAnudeep (Salesforce Developers) 
Hi Bharath, 

I have seen this behavior reported in the past. Here is what Salesforce R&D has advised

"We make a best-effort attempt to use the API name of a field in the Report REST or Metadata APIs, but since a column in a report may not always correspond to a field, there may be cases where we cannot do that. In those cases, the name of a field that is exposed by reports is meaningful only in the context of the report REST and Metadata API. The report column name corresponding to any custom field, for example, should always be the API name for that field."

Unfortunately, there is no way to get API names of standard fields through REST API. One of the reasons why the product team has designed it this way is, if a customer defines some column names in a report, they might coincide with the standard field names.

The standard field names get generated based on Standard report type definitions and other components that are part of internal Salesforce code.

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep