• Test User 101 9
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello all,

I'm building my first flow, which is now in flow builder. My first major hurdle is that I can't seem to send a string to an apex action, query some records using that string as a soql criterion, then return the list. 

My Apex action looks like this:
 

global class Flow_ChecklistTemplateItemGetter{
	@invocableMethod(label = 'Get Template Items' description = 'gets all Checklist Template Items whose "Applies_To" field contains the provided machine model')
	global static List<Checklist_Template_Item__c> getRelevantTemplateItems(List<String> modelList){
		
		String searchModel;
		
		// this will only be a single value
		for(String s : modelList){
			searchModel = s;
		}
		
		System.debug('SearchModel = '+searchModel);

		String queryString = 'Select Id, Checkbox_Options__c, Checklist_Template_Section__c, Objective__c, Required__c, Sort_Order__c From Checklist_Template_Item__c Where Applies_To__c Includes(:searchModel)';
		List<Checklist_Template_Item__c> itemList = Database.query(queryString);
		
	 	for(Checklist_Template_Item__c cti : itemList){
	 		System.debug('checklist template item = '+cti);
	 	}
	 	
	 	return itemList;
	}
}
"modelList" is only ever going to be a single value, which is why I assign it to its own string for querying. 

I get the error "The number of results does not match the number of interviews that were executed in a single bulk execution request". 
Well...no kidding. I don't want to only return one record just because I only had one string input. 

What I thought might be the reason was that my output variable was not a collection variable, but the collection variable I created in followup to that is un-selectable from my Apex action. 

I can only select variables that accept a single record. 
User-added image