+ Start a Discussion

How assign task to a Public Group in Apex Code ?



I created a custom controler in apex classes to create automaticly  a task.


I would like assign my task to a Public Group called "Production". I tried this :


tskNew = new Task();

tskNew.OwnerId = [SELECT Id,Name FROM Group WHERE Name ='Production' limit 1].Id;


But it doesn't work. i have this message : Assigned To: Assigned To ID: id value of incorrect type: 00GW0000000JXiSMAW


Thanks for your help.




Saikishore Reddy AengareddySaikishore Reddy Aengareddy

You can only assign User as owner to a task. 


You cannot assign a public group as owner to any object within salesforce. You can assign Queues to Lead, case and custom objects but NOT Groups.