Hi, I am working on a Flow with these goals:
1. Take a multi-select picklist field (Services_Provided__c) from an Intake__c record
2. Split each selected value into individual items
3. Create related records in Intake_Svc_Provided__c, with one record for each selected value
4. Text Field name is Svcs_Provided_Split__c
I have created a Record Triggered Flow using an Apex action to split out the values
(I had tried using StringWizard from UnofficialSF but installation fails because I need 'FlowActionsBasePack' version 2.36. This version is no longer available and when I download 'FlowActionsBasePack' it is version 3.19. )
APEX CLASS
public class IntakeServiceSplitter {
@InvocableMethod(label='Split Services Provided and Create Records')
public static void splitAndCreate(List<Id> intakeIds) {
List<Intake__c> intakes = [SELECT Id, Services_Provided__c FROM Intake__c WHERE Id IN :intakeIds];
List<Intake_Svc_Provided__c> newSvcRecords = new List<Intake_Svc_Provided__c>();
for (Intake__c intake : intakes) {
if (String.isNotBlank(intake.Services_Provided__c)) {
List<String> services = intake.Services_Provided__c.split(';');
for (String service : services) {
service = service.trim();
if (!String.isBlank(service)) {
newSvcRecords.add(new Intake_Svc_Provided__c(
Intake__c =
,
Svcs_Provided_Split__c = service
));
}
}
}
}
if (!newSvcRecords.isEmpty()) {
insert newSvcRecords;
}
}
}
I created a Collection Text Variable intakeIdCollection and allowed multiple values
I configured the Assignment element as intakeIdCollection Add RecordId
Then I have an Apex Action and in intakeIds I have RecordId (variable)
Having an issue with 2 things I think:
Assignment:
For Value, when I type in Record I have to select Triggering Record > Record ID
The in the
Apex Action
in the intakeIds box, I cannot just select record Id and it won't accept if I just paste in Record. Id
I tried deleting the Apex Action so it is created after my Resource intakeIdCollection was created and even closed flow and opened it again but that did not work. I also tried using a CollectionFormula resource of {!intakeIdCollection} but that did not work either.
My Flow debugs successfully but it is not getting any outputs to create records. I am adding a pic of my Flow.
#Flow
Looks good. Do the below steps:
1. Create a Collection Record Variable of your object type.
2. In this Assignment element add the Single variable to this collection using the "add" operator.
3. Now in the Create Records element use this collection variable.
That's all. Thank you