You need to sign in to do that
Don't have an account?
Create a Task for a Case
Hi
i created a case and i have case id and case number. now i am trying to create a task on this existing case number.
so do i have to create task or update task for that existing case number.
i am doing in this way :
Task task = new Task();
task.setWhatId(case_Id); // case_id contains the case id for the existing case where i want to create a task
task.setDescription("sample description ");
task.setRecordTypeId(id_record_type);
task.setOwnerId(id_owner);
// Create an array of SObjects to hold the accounts
SObject[] sObjects = new SObject[1];
// Add the accounts to the SObject array
sObjects[0] = task;
// Invoke the create call
SaveResult[] saveResults = sfdc.create(sObjects);
// Handle the results
for (int i=0;i<saveResults.length;i++) {
// Determine whether create succeeded or had errors
if (saveResults[i].isSuccess()) {
// No errors, so we will retrieve the id created for this index
System.out.println(saveResults[i].getId().getValue());
}
else {
System.out.println("Object is not Created");
}
}
however its not working. Could any body please help me on this.
thank u
Hi
thank u for reply
if (saveResults[i].isSuccess()) {
// No errors, so we will retrieve the id created for this index
System.out.println(saveResults[i].getId().getValue());
}
else {
System.out.println("Object is not Created");
}
it is not going into if, it is directly coming to else. is this the right way to create a task under a case or there is other way?
thank u
if (saveResults[i].isSuccess()) {
// No errors, so we will retrieve the id created for this index
System.out.println(saveResults[i].getId().getValue());
} else {
Error err = saveResults[i].getErrors()[0];
System.out.println("Error code: " + err.getStatusCode() + " Error Message: " + err.getMessage());
}
Cheers.
Hi
thank u
i got it. what's the problem was
thanks again
Hi
thank u for ur help
i got it what's the problem was
thanks again