I have a LWC that essentially collects data in a table format.

I am then using an apex action (apex class) to parse the text string output of the LWC back to a record - see the code below:

public without sharing class PointofConnSingle {
    //input details that comes to apex from flow
    public class FlowInputs{
        public string applicationIdString;
        public string propertyChildStringArray;

    @InvocableMethod(label='Point Of Connection Saving Single Apex')
    public static List<String> saveMainsData(List<FlowInputs> request){

        List<string> applicationIdList = new List <string>();
        List<string> propertyChildStringArrayList = new List<string>();
        List<string> resultResponse = new list<string>();
        List<property__c> newPropertyToInsertList = new List<property__c>();

        for(FlowInputs requestItem : request){           


            Id applicationId = Id.valueOf(applicationIdList[0]);        
            //main property array- processing Json
            List<PropertyJsonClass> mainPropList = PropertyJsonClass.parse(propertyChildStringArrayList[0]);
            //inserting property frist
            for(PropertyJsonClass resultPropItem: mainPropList) {                                  
                property__c newProperty = new property__c();
                newProperty.Application__c = applicationId;
                newProperty.Type_of_Property_POC__c = resultPropItem.propertyType;
                newProperty.Name = resultPropItem.propertyType;
                newProperty.Units__c = filterResponse(resultPropItem.unit);
                newProperty.Imp_Areas_M__c = filterResponse(resultPropItem.impAreas);
                newProperty.Name = resultPropItem.propertyType;
                system.debug('adding property records');
                insert newPropertyToInsertList;

        }catch(Exception e){
            resultResponse.add('INSERT Failed' + e);

        return resultResponse;
       private static integer filterResponse(String dataToFilter){
        if(dataToFilter!='' && dataToFilter!=null){
            return integer.valueOf(dataToFilter);
            return 0;

This works if the value put into the Units__c or Imp_Areas_M__c field is an integer but fails if a decimal is entered.

The data is entered via a LWC that outputs a text string that this code then parses into the fields

any ideas?

I assumed the Private static class at the bottom converts the value to a integer - but obviously not

Error Message is - The number of results does not match the number of interviews that were executed in a single bulk execution request.

1 Answer 1


It happens because if an exception is thrown, the catch statement adds 'INSERT Failed', but after catching you add an 'OK' message. Please move the 'OK' statement addition above before the catch block.

  • Thanks i will try this
    – Matt
    Apr 15, 2023 at 18:18
  • Sorry to be a pain i am not a coder - how would it be written - i have tried cutting a pasting but i am getting an error compliting
    – Matt
    Apr 15, 2023 at 18:21
  • ... insert newPropertyToInsertList; } /* add here */resultResponse.add('OK'); /* add here end */ }catch(Exception e){ resultResponse.add('INSERT Failed' + e); } /* remove resultResponse.add('OK') from there*/ return resultResponse; } ... Apr 27, 2023 at 10:18
  • @Matt here you go Apr 27, 2023 at 10:21
  • Thank you @Jack
    – Matt
    May 2, 2023 at 7:58

You must log in to answer this question.

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