• AnirudhGarg
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

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
     c.setFramework_Found_in_txt__c("ixE-4.18.0");
     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) {
     e.printStackTrace();
}