You need to sign in to do that
Don't have an account?
set record type on task created in apex
I want to set the record type on a task I have created in apex with code similar to below but I don't see any property on the task object where I can do this, any ideas?
Task myTask = new Task();
myTask.Subject = 'Follow up task for opportunity';
The bigger problem I am trying to solve is create tasks in a trigger on opportunity creation. I can do this ok but I want to make sure they can not be deleted without affecting the delete permissions on any other kind of task. I thought about doing this by creating a task with a different record type so I could assign a page layout to it where the delete button is not available. I don't know if there is another way.
you can set record type Id in task object , query record type against Name and Sobject Type
and set into new record
Hope this will help you out
Thanks,
Bala
All Answers
you can set record type Id in task object , query record type against Name and Sobject Type
and set into new record
Hope this will help you out
Thanks,
Bala
It really good to see that solution works for you
Thanks,
Bala
Thanks for the help. One thing: the query was missing WHERE. I've added it below:
myTask.RecordTypeId = [Select Id,SobjectType,Name From RecordType WHERE Name ='YOUR_TASK_RECORD_TYPE_NAME' and SobjectType ='Task' limit 1].Id;