You need to sign in to do that
Don't have an account?
Brandon 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:
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.
Please check with below thread from stack exchange community which explains how to set a nullable field back to null using the REST API.
- http://salesforce.stackexchange.com/questions/56407/need-to-set-a-nullable-field-back-to-null-using-the-rest-api
Hope this helps.Best Regards,
Nagendra.P
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.