0

I have researched StackExchange, as well as Salesforce Developer community. I cannot seem to get around this error. Ultimately, I am trying to pass into a screen flow a list of RecordTypes that a user is allowed to select. I have the following code below, compiles and runs in developer console (removing the invocable, global, and public lines). I have read that input and output must be the same size, and I have also read that it does not matter. I do not actually need any input in the scenario.

Below is my code. Note that List<List> PHolder only exists by recommendation of the other posts, however it is really useless for my purposes.

global class GetCaseRecordTypes {
    @InvocableMethod
    public static List<List<String>> CaseRecordTypes(List<List<String>> PHolder){
        List<List<String>> recordTypeNameList = new List<List<String>>();
        Schema.DescribeSObjectResult R = Case.SObjectType.getDescribe();
        List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();
        for( Schema.RecordTypeInfo recordType : RT ){
            List<String> RType = new List<String>();
            if(recordType.isAvailable() && recordType.Name!='Master'){
                RType.add(recordType.Name);
                recordTypeNameList.add(RType);
        }
    }
    System.debug(recordTypeNameList);
    return recordTypeNameList;
    }
}

1 Answer 1

2

You need to return an object for each flow input. As a further problem, you need to clone the list to avoid a different error. The following should work:

global class GetCaseRecordTypes {
    @InvocableMethod
    public static List<List<String>> CaseRecordTypes(List<List<String>> PHolder){
        List<List<String>> recordTypeNameList = new List<List<String>>();
        Schema.DescribeSObjectResult R = Case.SObjectType.getDescribe();
        List<Schema.RecordTypeInfo> RT = R.getRecordTypeInfos();
        List<String> RType = new List<String>();
        for( Schema.RecordTypeInfo recordType : RT ){
            if(recordType.isAvailable() && recordType.Name!='Master'){
                RType.add(recordType.Name);
            }
        }
        for(List<String> temp: PHolder){
            recordTypeNameList.add(RType.clone());
        }
        System.debug(recordTypeNameList);
        return recordTypeNameList;
    }
}

You must log in to answer this question.

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