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
Stephen Wood 5Stephen Wood 5 

Get value of a formula field in JSON response - REST API

Is it possible to have the REST API return the value of a formula field when creating a record? I know that the payload returns the record ID, but would like other field values returned as well in order to not have to make a second call. For example the response body for a new account might look like:
 
{
  "id" : "001D000000IqhSLIAZ",
  "errors" : [ ],
  "success" : true
  "Formula_field__c" : "Formula field value"
}

 
Best Answer chosen by Stephen Wood 5
JLA.ovhJLA.ovh
You could use the composite API https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite.htm
 

All Answers

LBKLBK
Fetching the record using SOQL after creation, and returning it as JSON would be a good idea. Because typical INSERT / UPSERT will return only IDs.
JLA.ovhJLA.ovh
You could use the composite API https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite.htm
 
This was selected as the best answer