You need to sign in to do that
Don't have an account?

INVALID_FIELD_FOR_INSERT_UPDATE on accountId field when trying to create Task
I am trying to create tasks through the webservice API. I have code that looks something like this:
List<sObject> objs = new List<sObject>;
foreach ... {
Task task = new Task();
task.AccountId = accountID;
task.WhatId = opportunityID;
task.Subject = subject;
task.Description = description;
task.ActivityDate = date;
task.IsClosed = isComplete;
task.Priority = "Normal";
task.Status = (isComplete) ? "Completed" : "In Progress";
objs.Add(task);
}
sObject[] objArray = objs.ToArray();
SaveResult[] resArray = new SaveResult[objs.Count];
DebuggingInfo debInfo = binding.create(sessionHeader, new AssignmentRuleHeader(), new MruHeader(), new DebuggingHeader(), new EmailHeader(), objArray, out resArray);
The accountIds and opportunityIds were retrieved earlier in the code through the API. I have confirmed that they are valid IDs, referring to the correct accounts and opportunities that already exist in the DB.
For each task that I try to inset, I receive the following error message:
Any idea on what the error message means, and how I can fix this so that I can insert tasks into the DB through the API? (And regarding the instruction to check the security settings of this field, etc, I have done some poking around in my account and I could not find where to do this, if this would indeed solve my problem).
Thanks!
Message Edited by yaakov on 03-04-2008 11:26 PM
List<sObject> objs = new List<sObject>;
foreach ... {
Task task = new Task();
task.AccountId = accountID;
task.WhatId = opportunityID;
task.Subject = subject;
task.Description = description;
task.ActivityDate = date;
task.IsClosed = isComplete;
task.Priority = "Normal";
task.Status = (isComplete) ? "Completed" : "In Progress";
objs.Add(task);
}
sObject[] objArray = objs.ToArray();
SaveResult[] resArray = new SaveResult[objs.Count];
DebuggingInfo debInfo = binding.create(sessionHeader, new AssignmentRuleHeader(), new MruHeader(), new DebuggingHeader(), new EmailHeader(), objArray, out resArray);
The accountIds and opportunityIds were retrieved earlier in the code through the API. I have confirmed that they are valid IDs, referring to the correct accounts and opportunities that already exist in the DB.
For each task that I try to inset, I receive the following error message:
Error code is: INVALID_FIELD_FOR_INSERT_UPDATEThe error code and message seem to imply that I cannot create a task with an accountId. This seems strange, as I want to relate the task to the accountId.
Error message: Unable to create/update fields: AccountId. Please check the security settings of this field and verify that it is read/write for your profile.
Any idea on what the error message means, and how I can fix this so that I can insert tasks into the DB through the API? (And regarding the instruction to check the security settings of this field, etc, I have done some poking around in my account and I could not find where to do this, if this would indeed solve my problem).
Thanks!
Message Edited by yaakov on 03-04-2008 11:26 PM
All Answers
Thanks very much for posting this, as this is obviously not correctly documented.
Here's my followup question: Suppose you want the task to be associated with both an account an an opportunity?. If you assign the AccountID to the WhatID field, what field do you assign the OpportunityID to?
There's no opportunityId in Task object.
Does anyone know how to accomplish the original request? Which is to update a task in a way that it has a reference to an opportuniy and a reference to an account.
Thanks,
You'd set the WhatId to be the id of the opportunity.
Hi,
If you set the WhatId to a 'Case' it does not pickup the AccountID automatically but it does with all other objects. I have had this support ticket open with Support for over 2 weeks. Does anyone know why or if there is a work around?
Thanks