I have an invocable method which is invoked when a platform event is published. So far the invocable method invokes on time and some elements of the data are extracted from the platform event.
Now when I do a SOQL based on one of the elements of the extracted data, I dont get any results at all. And when I do the same SOQL with the extracted data on the query editor of the developer console the right results are returned.
I did some system.debug statements to see if they are the right inputs for the SOQL and they all seem to be correct.
Here is my code. This code does not produce any results, it just does not return anything.
@InvocableMethod(label='Invocable Method')
public static List<Results> processResponses(List<Requests> input) {
String fileName = input[0].fileName;
String fileContent = input[0].fileContent;
String patientIcn;
List<String> fileContentSplits = fileContent.split('\n');
for (String s: fileContentSplits) {
if (s.startsWith('SID')) {
List<String> sidSplits = s.split('\\^');
for (Integer i = 0; i < sidSplits.size(); i++) {
if (i == 1) {
patientIcn = sidSplits[i];
}
}
}
}
System.debug('patientIcn -'+patientIcn); //This prints the right value
List<WorkOrder> workOrder = [SELECT Id from WorkOrder WHERE Account.ICN__c =:patientIcn AND Status = 'Completed' LIMIT 1];
System.debug(workOrder);//This has no results
ContentVersion contentVersionFile = new ContentVersion();
contentVersionFile.Title = fileName;
contentVersionFile.PathOnClient = fileName;
contentVersionFile.VersionData = Blob.valueOf(fileContent);
contentVersionFile.ContentLocation = 'S';
List<Results> results = new List<Results>();
Results result = new Results();
if (workOrder.size() > 0) {
insert contentVersionFile;
result.contentVersionFileId = contentVersionFile.Id;
result.workOrderId = workOrder[0].Id;
result.status = 'pass';
results.add(result);
}
System.debug('Results-'+results);//This has no return as well.
return results;
}
I am doing some linking of the content document file after this invocable method is run and because the soql does not return anything the final linking process fails as well.