You need to sign in to do that
Don't have an account?
Creating a Task from Apex
I'm trying to create a Task from Apex for the current logged in user. It seems simple enough, and I'm doing pretty much exactly what is specified in the Developer Guide:
//create a task for the user
//Task newTask = new Task(Subject='Complete Survey for Transaction');
Task newTask = new Task(Description = 'Survey Transaction',
Priority = 'Normal',
Status = 'Inbound Email',
Subject = 'Other',
IsReminderSet = true,
ReminderDateTime = System.now()+1,
WhoId = userContact[0].ContactId );
insert newTask;
But I keep getting this exception:
Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Free-form text is not allowed for the Subject field. Please select a pre-determined value from the picklist.: [Subject]
The subject that I've specified ('Other') is in the Task subject picklist, and Task.Subject is supposed to be a String, so I don't know what else I'm supposed to do to get it to match up my subject with the pre-determined values...
Anybody happen to know?
Thanks,
Tom
Do you have any custom validation rules on the Task object (Setup -> Customize -> Activities -> Task Validation Rules)?
All Answers
Do you have any custom validation rules on the Task object (Setup -> Customize -> Activities -> Task Validation Rules)?