0

when insert a record into salesforce and the JSON file contains one field from backend, which may not yet be in Salesforce, is it possible, that the record will be created with the correct field and leave out the missing one, instead of giving an error msg and not insert?

Example when trying to insert a person account: { "Firstname":"John", "Lastname": "Doe", "recordTypeId": "0127R0000007XXXXX", "AccessRestricted__c":"true" }

And let's say Field "AccessRestricted__c" is not in Salesforce. Is there a way, that the record is nevertheless inserted, just leaving out this field?

Thanks RRI

2
  • This question needs some elaboration with more details - the input JSON and corresponding SFDC schema. Use edit
    – cropredy
    Apr 30 '21 at 17:16
  • Added an example.
    – RRI
    Apr 30 '21 at 20:33
2

So, if the caller is using the OOTB SFDC REST Api to insert an Sobject, all fields in the JSON payload need to be visible to the running user (the API user)

You can work around this if :

  • you change the endpoint to a custom APEX Rest endpoint
  • where the input can be parsed from a Map<String,Object> and
  • the map keys can be compared against SObjectDescribe and
  • fields not known to the schema can be ignored before the Apex REST service does a Database.insert.

To avoid hardcoding any fieldnames, use the Sobject class put method

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.