+ Start a Discussion
Antoine LeleuAntoine Leleu 

Update case field from Java client App



i'm trying to code an client app to update cases.

 I use the update() call to update a custom field. But when i run my application, i have this error : 


"ERROR updating record: Unable to create/update fields: CaseNumber"


However i don't set the case number in my case. Is it possible to update cases with the update() call ?

This my code :


private static void updateCases() {
System.out.println("Querying for the cases...");
try {
// query for the cases      
QueryResult queryResults = connection.query("SELECT Id, CaseNumber " +
      "FROM Case WHERE RT_id__c = '4622'");
     if (queryResults.getSize() > 0) {
     //Define records
     Case[] records = new Case[queryResults.getSize()];
     for (int i=0;i<queryResults.getRecords().length;i++) {
     // cast the SObject to a strongly-typed Case
     Case c = (Case)queryResults.getRecords()[i];
     System.out.println("Id: " + c.getId() + " - CaseNumber: "+c.getCaseNumber());
     System.out.println("Update cases...");
     //update case
     records[i] = c;
     SaveResult[] saveResults = connection.update(records);
         // check the returned results for any errors
      for (int i=0; i<saveResults.length; i++) {
      if (saveResults[i].isSuccess()) {
      System.out.println(i+". Successfully updated record - Id: " + saveResults[i].getId());
      } else {
      Error[] errors = saveResults[i].getErrors();
      for (int j=0; j<errors.length; j++) {
      System.out.println("ERROR updating record: " + errors[j].getMessage());
} catch (Exception e) {

From the Salesforce docs:


Certain records cannot be updated via the API. To update a record via the update() call, its object must be configured as
updateable (updateable is true). To determine whether an object can be updated, your client application can invoke the
describeSObjects() call on the object and inspect its updateable property.




You can try checking if this object can be updateable.


Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.


Antoine LeleuAntoine Leleu


Thanks Satish,


i checked the updateable field for the Case SObject and it retrun "True".

But i already the same error message.




1. CaseNumber Field:  Assigned automatically when each case is inserted. It can't be set directly, and it can't

be modified after the case is created.

2. You try to remove CaseNumber from SOQL statement.


Hope this helps.




QueryResult queryResults = connection.query("SELECT Id, CaseNumber " +
      "FROM Case WHERE RT_id__c = '4622'");
From the query remove CaseNumber and try to update, it works for me that way.
QueryResult queryResults = connection.query("SELECT Id " +
      "FROM Case WHERE RT_id__c = '4622'");
This happens when CaseNumber is a autoNumber type. If you really need casenumber, copy it in another field in salesforce and try to use that field in API.
Bindhyachal Kumar SinghBindhyachal Kumar Singh
Hi Samba,

It really help me. I have just removed casenumber from SOQL quesy and able to update case. 

Thank You very much.