+ Start a Discussion
zapierzapier 

"Field Required" Logic Question

Here is a field extracted from the REST API endpoint (xx.salesforce.com/services/data/v23.0/sobjects/xx/describe):

 

{
   "length":0,
   "name":"ActivityDate",
   "type":"date",
   "defaultValue":null,
   "label":"Due Date Only",
   "updateable":true,
   "precision":0,
   "scale":0,
   "controllerName":null,
   "byteLength":0,
   "unique":false,
   "calculated":false,
   "nameField":false,
   "sortable":true,
   "filterable":true,
   "nillable":true,
   "caseSensitive":false,
   "inlineHelpText":null,
   "writeRequiresMasterRead":false,
   "externalId":false,
   "idLookup":false,
   "createable":true,
   "soapType":"xsd:date",
   "autoNumber":false,
   "restrictedPicklist":false,
   "namePointing":false,
   "custom":false,
   "defaultedOnCreate":false,
   "deprecatedAndHidden":false,
   "htmlFormatted":false,
   "defaultValueFormula":null,
   "calculatedFormula":null,
   "picklistValues":[

   ],
   "dependentPicklist":false,
   "referenceTo":[

   ],
   "relationshipName":null,
   "relationshipOrder":null,
   "digits":0,
   "groupable":true
}

 

When POSTing an Object using the REST API, we are given an error "Field ActivityDate Required" if we do not include the above field.

 

My question: from the definition above, what is the correct logic to decide if any individual field is required or not when creating new Objects?

Best Answer chosen by Admin (Salesforce Developers) 
Noam.dganiNoam.dgani

It will be a combination:

 

1. if its creatable ("creatable":true)

2. not nillable ("nillable":false)

 

and pending your logic, you can also ask if it has a default value:

"defaultOnCreate":false

 

hope this helps - if it does, kindly mark your post as resolved

All Answers

zapierzapier

Bump. I imagine this has to be Salesforce 101 but I couldn't find it anywhere in the documentation. Thanks in advance.

Noam.dganiNoam.dgani

It will be a combination:

 

1. if its creatable ("creatable":true)

2. not nillable ("nillable":false)

 

and pending your logic, you can also ask if it has a default value:

"defaultOnCreate":false

 

hope this helps - if it does, kindly mark your post as resolved

This was selected as the best answer
zapierzapier

"defaultedOnCreate" was the missing piece. I appreciate your help.

Sornakumar SundararajanSornakumar Sundararajan
Hi, even with the above logic, ActivityDate need not be present in the request right?
createable : true, nillable : true, defaultedOnCreate : false - so the field can be null. How did you identify this field was required?