function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rich.ax131Rich.ax131 

Task creation

I'm trying to automate task creation, but I'm getting an error message indicating that the AccountId field is not updateable. If I don't set a value for AccountId the task appears to be created without error, but I can't find it anywhere. Without the AccountId association I'm not sure what the "tie" is between the task and anythng else.

Any suggestions?

Thanks,
Rich
Rich.ax131Rich.ax131
Anyone? I just dumped out all my Task table data so I could review. I found the newly created task, but the AccountId field was not populated.

Ideas?
Rich.ax131Rich.ax131
I also tried first creating the task and then going back and updating the AccountId field. No dice. Same error.

I'm dying here . . .
EnderEnder
Rich,

You are correct that the accountid field is not updatable. It is generated automatically if you assign the task to a contact.

However, what you are looking for is the WHATID field. You set this field with the account id if you wish to assign the task to an account.


========================================================================================
To dive deeper into the Task object:

Since the task object can be assigned to either Accounts, Opportunities, Contacts or Leads there are two generic fields to set for assignment. If you are assigning the Task to a person (Contact/Lead) you set the WHOID; if you are assigning the Task to an object (Account/Opportunity) you set the WHATID.

Admittedly, the autogenerated AccountId field is confusing because of the name collision. At least the describe shows it not to be updateable which helps a little.

Cheers.
Rich.ax131Rich.ax131
That's what I needed to know. Thank you for your help.

Rich