You need to sign in to do that
Don't have an account?
João Almeida
Apex: start flow with record collection input
I'm trying to start a flow that receives a record collection as input.
I have the following code:
List<YB_Dosage_Line__c> parsedDosagelines =(List<YB_Dosage_Line__c>)JSON.deserializeStrict(serializedApplicationRecord,List<YB_Dosage_Line__c>.class); Map<String, Object> flowParams = new Map<String, Object>{'dosageLines' => parsedDosagelines}; Flow.Interview.YB_Dosage_Lines_Process_Related_Generic_Group_and_Product_Family flowInstance = new Flow.Interview.YB_Dosage_Lines_Process_Related_Generic_Group_and_Product_Family(flowParams); flowInstance.start();
But, it throws the following error:
Malformed JSON: Expected '[' at the beginning of List/SetAny ideas?
The error message you're encountering indicates that the JSON string serializedApplicationRecord is not valid JSON because it does not start with a square bracket '[' as expected for a List/Set.
To resolve this issue, you need to ensure that the JSON string you are trying to deserialize is properly formatted and begins with a '[' to indicate the start of a list. Here's an example of a valid JSON string representing a list of YB_Dosage_Line__c objects:
If you find my answer helpful, please mark it as the best answer. thanks!