Create a group and group Member through Apex @future

public class FutureClass {
    @future
    public static void callme(ID myId){
        GroupMember gmr=new GroupMember();
        gmr.GroupId=myId;
        gmr.UserOrGroupId=userInfo.getUserId();
        insert gmr;
    }
}

public class FutureExample {
    public void show(){
        Account ac=new Account(Name='FutureClassEx2');
        insert ac;
        Group newGroup=new Group();
        newGroup.Name=ac.name;
        newGroup.DoesIncludeBosses=false;
        insert newGroup;
        FutureClass.callme(newGroup.Id);
    }
}

Comments

Popular posts from this blog

Page Layouts

SOQL Scenario-1