I am writing a sample class to split a fields into several fields depending on the separator character '\\|!\\|'
.
My problem is when I ran the flow, it's not possible to me to retrieve the values returned from the Apex Action.
It's maybe a problem of the method declaration with a List of List and/or the size of the List returned in the output that don't match the size of the List entered?
public class ImplementCrossCellSolution3 {
@InvocableMethod(label='Parse Comments into Fields Version 3')
public static List<List<OutputVariables>> parseComments(List<InputVariables> recordComments){
String comments = recordComments[0].recordComments;
HubSpotCommentsInfo HubInfo = new HubSpotCommentsInfo();
List<List<OutputVariables>> outputHubSpotCommentsInfo = new List<List<OutputVariables>>(); //===============
List<OutputVariables> outputresults = new List<OutputVariables>();
OutputVariables outputresult = new OutputVariables();
List<String> parts = comments.split('\\|!\\|');
Integer index = 0;
for(String part : parts) {
part = part.trim();
switch on index {
when 0 {
HubInfo.fields1 = part;
outputresult.fields1 = part;
system.debug(HubInfo.fields1);
system.debug(outputresult.fields1);
}
when 1 {
HubInfo.fields2 = part;
outputresult.fields2 = part;
system.debug(HubInfo.fields2);
system.debug(outputresult.fields2);
}
when 2 {
HubInfo.fields3 = part;
outputresult.fields3 = part;
//system.debug(HubInfo.fields3);
//system.debug(outputresult.fields3);
}
when 3 {
HubInfo.fields4 = part;
outputresult.fields4 = part;
//system.debug(HubInfo.fields4);
//system.debug(outputresult.fields4);
}
}
index++;
outputresults.add(outputresult);
}
//return outputresults;
outputHubSpotCommentsInfo.add(outputresults); // ===================
return outputHubSpotCommentsInfo; // ====================
}
public class InputVariables { //=====================
@InvocableVariable
public String recordComments;
}
public class OutputVariables {
@InvocableVariable
public String fields1;
@InvocableVariable
public String fields2;
@InvocableVariable
public String fields3;
@InvocableVariable
public String fields4;
}
}