Ok, I first want to give full credit for original code designer Shane McLaughlin for creating a bunch of very useful process builder bolt-ons. They can be found here: https://github.com/mshanemc/processBuilderBlocks

Now that I have given credit. I am trying to use his code to create an invocable class to handle public group membership. I was able to modify the main class but I am getting an error on the test class that I can't figure out. Can anyone help me out?

Main Class:

public with sharing class PB_AddToPublcGroup {

    @InvocableMethod(label='Add User to Public Group')
    public static void AddPublicGroup(list<AddGroupMember> requests) {

        list<string> output = new list<string>();

        for (AddGroupMember request:dedupe(requests)){
            //future methods can only accept primitives, so we serialize to a list of string



    //what Process Builder/Flow Builder can reference for the input variables
    public class AddGroupMember {
        @InvocableVariable(required=true label='Public Group Name')
        public String PubGroupName;

        @InvocableVariable(required=true label='User Id')
        public Id UserId;

    public static list<AddGroupMember> dedupe(list<AddGroupMember> input){
        set<AddGroupMember> temp = new set<AddGroupMember>(input);
        return new list<AddGroupMember>(temp);

    //has to be handled as an @future transaction because the mixed DML issue!
    public static void AddGroupsLater (list<string> requests){
        list<GroupMember> gpMembers = new list<GroupMember>();

        for (string request:requests){

            //turn it back into the request object per Quinton Wall
            AddGroupMember APSR = (AddGroupMember)JSON.deserialize(request, AddGroupMember.class);
            Group groupId = [Select ID FROM Group WHERE Name = :APSR.PubGroupName];

            GroupMember groupMem = new GroupMember();
            groupMem.UserOrGroupId  = APSR.UserId;
            groupMem.GroupId        = groupId.Id;

        insert gpMembers;


Test Class:

private class test_PB_Addons {

    //tests the class across a whole bunch of permissions being added.
    @isTest static void testPublicGroup() {
        integer userCount=5;
        //create users
        list<user> users = createUsers(userCount);
        //create a Public Group
        Group GP = createGroup();
        //create the inner class object and add to list
        list<PB_AddToPublicGroup.AddGroupMember> GMRs = new list<PB_AddToPublicGroup.AddGroupMember>();
        for (user u:users){
            PB_AddToPublicGroup.AddGroupMember GMR = new PB_AddToPublicGroup.AddGroupMember();
            GMR.UserId = u.id;
            GMR.PubGroupName = GP.Name;

        //call the invocable method

        //asserts--check that user is in the group
list<PermissionSetAssignment> PSAs = [select Id, AssigneeId, PermissionSetId 
from PermissionSetAssignment
where AssigneeId in: users and PermissionSetId =: PS.Id];

system.assertEquals(userCount, PSAs.size()); 

    public static list<user> createUsers(integer numberOfUsers){

    private static Group createGroup(){

The error in test class is this line:

//create the inner class object and add to list

list<PB_AddToPublicGroup.AddGroupMember> GMRs = new list<PB_AddToPublicGroup.AddGroupMember>();


Invalid type: PB_AddToPublicGroup.AddGroupMember

2 Answers 2


This looks like a simple type to me ,

Try using the below

list<PB_AddToPublcGroup.AddGroupMember> GMRs = new list<PB_AddToPublcGroup.AddGroupMember>();

Observe your class name is "PB_AddToPublcGroup"

  • 1
    It would probably be better to fix the typo in the original class name than propagate it. You should probably also mention what the typo is, it's kind of hard to see (missing i in Public).
    – Adrian Larson
    Commented Aug 27, 2016 at 12:15

I had the same issue. But changing the name of the inner class worked out. It's weird but there are issues pertaining around the invocable classes and methods. My invocable method was not visible in the flow but when I moved it to a new class, it worked.

You must log in to answer this question.

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