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
DeVerl StokesDeVerl Stokes 

Creating a case with the rest API always sets Closed (IsClosed) to true (1)

I am using the rest API to create a new case. Nearly everything is working correctly, except that new cases are always created with Closed (IsClosed) set to true (1).

If I try to set Closed, I get INVALID_FIELD:

"body": "[{\"message\":\"No such column 'Closed' on sobject of type Case\",\"errorCode\":\"INVALID_FIELD\"}]"

If I try to set IsClosed, I get INVALID_FIELD_FOR_INSERT_UPDATE:

 "body": "[{\"message\":\"Unable to create\/update fields: IsClosed. Please check the security settings of this field and verify that it is read\/write for your profile or permission set.\",\"errorCode\":\"INVALID_FIELD_FOR_INSERT_UPDATE\",\"fields\":[\"IsClosed\"]}]"



If I do a describe on the Case object, the result includes this (IsClosed):

[18] => Array
                        (
                            [aggregatable] => 
                            [autoNumber] => 
                            [byteLength] => 0
                            [calculated] => 
                            [calculatedFormula] => 
                            [cascadeDelete] => 
                            [caseSensitive] => 
                            [controllerName] => 
                            [createable] => 
                            [custom] => 
                            [defaultValue] => 
                            [defaultValueFormula] => 
                            [defaultedOnCreate] => 1
                            [dependentPicklist] => 
                            [deprecatedAndHidden] => 
                            [digits] => 0
                            [displayLocationInDecimal] => 
                            [encrypted] => 
                            [externalId] => 
                            [extraTypeInfo] => 
                            [filterable] => 1
                            [filteredLookupInfo] => 
                            [groupable] => 1
                            [highScaleNumber] => 
                            [htmlFormatted] => 
                            [idLookup] => 
                            [inlineHelpText] => 
                            [label] => Closed
                            [length] => 0
                            [mask] => 
                            [maskType] => 
                            [name] => IsClosed
                            [nameField] => 
                            [namePointing] => 
                            [nillable] => 
                            [permissionable] => 
                            [picklistValues] => Array
                                (
                                )

                            [precision] => 0
                            [queryByDistance] => 
                            [referenceTargetField] => 
                            [referenceTo] => Array
                                (
                                )

                            [relationshipName] => 
                            [relationshipOrder] => 
                            [restrictedDelete] => 
                            [restrictedPicklist] => 
                            [scale] => 0
                            [soapType] => xsd:boolean
                            [sortable] => 1
                            [type] => boolean
                            [unique] => 
                            [updateable] => 
                            [writeRequiresMasterRead] => 
                        )


Further, if I go to the web interface and try change the value of the Status field from Closed to New, it shows up as changed (red text), but reverts when I press the Save button.

Any tips on how to create a new case, using the rest API, with a status of "New" and without setting Closed (or IsClosed)?
Best Answer chosen by DeVerl Stokes
Chris  ByromChris Byrom
If you look at the in Salesforce in the setup under Case --> Fields, you can see all the picklist values. The ones that will cause the case to be closed will have checkbox checked. This should have nothing to do with the status automatically changing though. I would look at validation rules, workflows, and triggers to see if something is setting changing this value. You could also setup a debug log for whatever user account you are using and see what all is happening when you send your request.

All Answers

Chris  ByromChris Byrom
You can't set the IsClosed field. It is controlled by the Status. If you look at the values in the status field, you can see which one will mark a case as closed, and which ones will mark it as not closed. If the field is not being saved in the web interface something is preventing it from being set back to New. It could be a workflow rule, validation, or trigger doing this. Hope this helps.
DeVerl StokesDeVerl Stokes

Thanks Chris,

I am trying to set the Status field to "New", but new cases are showing up as "Closed". Here is a sample of the JSON data I am posting (some of the data replaced with "###"):

{"Type":"Feature Request","Origin":"Web","Status":"New","Subject”:”###“,”SuppliedName”:”###”,”SuppliedEmail”:”###”,”Description”:”###”}

Origin is correctly being set to "Web" in new cases, but Status is always "Closed".

> If you look at the values in the status field, you can see which one will mark a case as closed, and which ones will mark it as not closed.

I am not following this statement. When I do a describe on the Case object, it includes the followng description of the Status field:

[12] => Array
                        (
                            [aggregatable] => 1
                            [autoNumber] => 
                            [byteLength] => 120
                            [calculated] => 
                            [calculatedFormula] => 
                            [cascadeDelete] => 
                            [caseSensitive] => 
                            [controllerName] => 
                            [createable] => 1
                            [custom] => 
                            [defaultValue] => New
                            [defaultValueFormula] => 
                            [defaultedOnCreate] => 1
                            [dependentPicklist] => 
                            [deprecatedAndHidden] => 
                            [digits] => 0
                            [displayLocationInDecimal] => 
                            [encrypted] => 
                            [externalId] => 
                            [extraTypeInfo] => 
                            [filterable] => 1
                            [filteredLookupInfo] => 
                            [groupable] => 1
                            [highScaleNumber] => 
                            [htmlFormatted] => 
                            [idLookup] => 
                            [inlineHelpText] => 
                            [label] => Status
                            [length] => 40
                            [mask] => 
                            [maskType] => 
                            [name] => Status
                            [nameField] => 
                            [namePointing] => 
                            [nillable] => 1
                            [permissionable] => 
                            [picklistValues] => Array
                                (
                                    [0] => Array
                                        (
                                            [active] => 1
                                            [defaultValue] => 
                                            [label] => On Hold
                                            [validFor] => 
                                            [value] => On Hold
                                        )

                                    [1] => Array
                                        (
                                            [active] => 1
                                            [defaultValue] => 
                                            [label] => Escalated
                                            [validFor] => 
                                            [value] => Escalated
                                        )

                                    [2] => Array
                                        (
                                            [active] => 1
                                            [defaultValue] => 
                                            [label] => Closed
                                            [validFor] => 
                                            [value] => Closed
                                        )

                                    [3] => Array
                                        (
                                            [active] => 1
                                            [defaultValue] => 1
                                            [label] => New
                                            [validFor] => 
                                            [value] => New
                                        )

                                )

                            [precision] => 0
                            [queryByDistance] => 
                            [referenceTargetField] => 
                            [referenceTo] => Array
                                (
                                )

                            [relationshipName] => 
                            [relationshipOrder] => 
                            [restrictedDelete] => 
                            [restrictedPicklist] => 
                            [scale] => 0
                            [soapType] => xsd:string
                            [sortable] => 1
                            [type] => picklist
                            [unique] => 
                            [updateable] => 1
                            [writeRequiresMasterRead] => 
                        )
 

Chris  ByromChris Byrom
If you look at the in Salesforce in the setup under Case --> Fields, you can see all the picklist values. The ones that will cause the case to be closed will have checkbox checked. This should have nothing to do with the status automatically changing though. I would look at validation rules, workflows, and triggers to see if something is setting changing this value. You could also setup a debug log for whatever user account you are using and see what all is happening when you send your request.
This was selected as the best answer
DeVerl StokesDeVerl Stokes
Hi Chris, It turns out it was a trigger. It took me a while to find it, but once found (and disabled) life is good again. Thank you very much!
Chris  ByromChris Byrom
You are welcome. Pesky triggers. Just make sure it was doing anything useful as well as autoclosing your cases lol.