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
Vijay Kumar Rebbala 1Vijay Kumar Rebbala 1 

How to create a Public Group through Apex class?

Hi All.
I have a scenario, where i need to create a Public Group through an Apex Class.
I need help.
Best Answer chosen by Vijay Kumar Rebbala 1
surasura
try below code to create a group 
Group test = new Group();
test.Name = 'Test Group';
insert test;

for more infromation refer https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_group.htm

All Answers

surasura
try below code to create a group 
Group test = new Group();
test.Name = 'Test Group';
insert test;

for more infromation refer https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_group.htm
This was selected as the best answer
Vijay Kumar Rebbala 1Vijay Kumar Rebbala 1
What is Type attribute here. I'm gonna use this group in a queue>
surasura
use Regular 

Regular—Standard Public Group. When you create() a Group, its type must be Regular, unless a partner portal is enabled for the organization, in which case the type can beRegular or PRMOrganization.
Vijay Kumar Rebbala 1Vijay Kumar Rebbala 1
@sura

Can we create queues in the same way??
CEBU ISRCEBU ISR
@Vijay Kumar Rebbala 1

Yes

{
    "Name": "Group00014",
    "DeveloperName": "Group00014",
    "Type": "Queue",
    "Email": "group00014@domain.com.ph",
    "DoesSendEmailToMembers": true,
    "DoesIncludeBosses": true
}