You need to sign in to do that
Don't have an account?
Antoine Leleu
Update case field from Java client App
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();
}
From the Salesforce docs:
Link:
http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content/sforce_api_calls_update.htm?SearchType=Stem
You can try checking if this object can be updateable.
Regards,
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.
Thanks Satish,
i checked the updateable field for the Case SObject and it retrun "True".
But i already the same error message.
Antoine
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.
Thanks,
Samba
It really help me. I have just removed casenumber from SOQL quesy and able to update case.
Thank You very much.