You need to sign in to do that
Don't have an account?
AlecS
Create a task under my custom object
I have a custom object Invoice. I want that when a certain action is performed, it must keep track of that task under that object.
I have this code in one of my class to create the task.
Task inv_task = new Task(); inv_task.WhatId = theInvoice.id; inv_task.WhoId = theInvoice.Contract__r.Name; inv_task.Subject = 'Invoice Emailed'; inv_task.status = 'Completed'; inv_task.description = 'Invoice emailed'; insert inv_task;
But I get this error message:
Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Contact/Lead ID: id value of incorrect type: 00530000000cIRWAA2: [WhoId]
Error is in expression '{!doMyApexLogic}' in component <apex:page> in page apexbuttonpage
How can I create a task. Please help!
Thanks!
You can't assign a 005 ("User") to WhoID (must be 003 ("Contact") or 00Q ("Lead")). Instead, to assign the task to a user, use OwnerId instead. Try looking at the SOAP Developer's Guide for details on standard object fields, such as Task.
All Answers
You can't assign a 005 ("User") to WhoID (must be 003 ("Contact") or 00Q ("Lead")). Instead, to assign the task to a user, use OwnerId instead. Try looking at the SOAP Developer's Guide for details on standard object fields, such as Task.
you need to
Thanks, sfdcfox!