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
Antoine_LeleuAntoine_Leleu 

How assign task to a Public Group in Apex Code ?

Hello,

 

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.

 

Antoine

 

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.