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
Brandon WhiteBrandon White 

Case Status is nillable but cannot be set to null through REST API?

We have noticed some strange behavior when trying to manipulate the Status field through the Force.com REST API. Take cases as an example:

When we fetch the field metadata (/services/data/v37.0/sobjects/Case/describe), we can see that the Status field is nillable:

{
      "name": "Status",
      "nillable": true,
... // other properties omitted for brevity
}

We have attempted to update an associating Case instance and set the value of this field to null like so:

PATCH /services/data/v37.0/sobjects/Case/<id>
Payload:
{
    "Status": null
}

We get a 204 error code suggesting the request was successful. But when we fetch the associating Case, the Status field retains the picklist value it had immediately before the PATCH request.

This behavior is different from any other standard or custom picklist that we have defined on our Case objects:
  • If a picklist field has nillable = false, then we get a 400 error response when we attempt to set the value to null. That matches our expectations because this field requires a non-null value.
  • If any other picklist field has nillable = true, then we can set the picklist field to a null value. A subsequent fetch of that Case shows that the picklist field value is indeed null.
Given the behavior of the Status field today, it seems like it would be more appropriate for the Status field metadata to specify nillable = false instead of true to reflect the fact that it seems to require a non-null field value. Ideally the server would also return an error if a client attempts to set it to null.
NagendraNagendra (Salesforce Developers) 
Hi Brandon,

Please check with below thread from stack exchange community which explains how to set a nullable field back to null using the REST API. Hope this helps.

Best Regards,
Nagendra.P
Brandon WhiteBrandon White
Hello Nagendra:

Thanks for the response but I don't see how the answers to that question would resolve our issue here. As mentioned in the question above, we found through trial-and-error that we could set a picklist field's value to null if the picklist metadata said nillable = true. But the only exception to this rule is the Status field which behaves as I described above.

It really seems like the Status field metadata should say that nillable = false if the server wants to enforce non-null field values. And it also seems rather strange that the server would return a successful error code and ignore the request that tried to set the field value to null. I would categorize this behavior as a bug with the Salesforce API.