Salesforce allows us to create task with ownerId as single user/to a queue through apex. I would like to know if it's possible to create a task with ownerId as publicGroup ID. I know that we can query the group members and create a task for each user from that group.

Below is the sample code that I tried and which have me error as,

Group g = [SELECT Name
                FROM Group
                WHERE Name = 'Test Group' LIMIT 1];
ID qID = g.ID;
List<Task> tList = new List<Task>();
Task t = new Task();
t.OwnerId = qID;
insert tList;


enter image description here

Just looking for a confirmation on this part.

  • Hi KSL, You need to query the public group id in the query Dec 16, 2021 at 8:20
  • @AnkaiahBandi, It's not required to query the Id field separately in SOQL
    – KSL
    Dec 16, 2021 at 8:36
  • As per my investigation public groups will not own the record. Please refer this [link] (salesforce.stackexchange.com/questions/319229/…) Dec 16, 2021 at 9:02
  • Yes @TSmith, It is enabled
    – KSL
    Dec 16, 2021 at 9:15
  • 1
    @TSmith, The group has GroupMembers. I agree with you on assigning separate task to each GroupMember. My question is about is there any possibility to directly assign to Group. I think the other reply in the comments has provided the info to us.
    – KSL
    Dec 16, 2021 at 9:58

1 Answer 1


Only Queues and Users may own records. Thus, you cannot use a Public Group directly to assign a task to multiple users. It is trivial to copy a Public Group to a Queue, however, since they share the same base object, the Group object.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .