We have an application that creates accounts on Salesforce using REST API populating them with data from an external database.

The problem we have encountered is that if the client (the owner of the Salesforce org we are creating accounts in) has defined custom required fields in his account object, we get an error that we are missing fields. This is expected behavior, after all. We only provide the fields we know about: the standard Account object fields.

One solution is to call the "describe" REST query for the Account object, scan all the fields for required ones, check the type, and add the field and some default value to our Account object before sending it to Salesforce. (In the case of a picklist field, we'd have to scan the list of valid choices and choose one). The problem with this solution is that it needs to be done for every created account, since we never can know when the admin has added a new custom required field.

My question is, has anyone dealt with this kind of issue, and if so, what was your solution?

  • 1
    Can they define meaningful defaults for the required fields from their end in Salesforce? Such as with Workflow, Triggers, or even on the fields themselves. Seems like a safer option as they are in control of their custom fields. – Daniel Ballinger Jun 7 '17 at 2:51
  • This is an excellent idea! I actually changed one of the fields in the picklist to "default" and no longer got the error for the missing field when I made the API call. It seems like a reasonable request to ask the admin to set a default value for all required fields in objects that are to be imported using the API. The only situation in which this wouldn't work would be a case where the admin deliberately didn't choose a default because he wants the user to select a value explicitly. – Kesty Jun 7 '17 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.