I created a flow using Flow designer and it is a FSL mobile flow. Here I basically uploading a file and then using the same for Einstein Prediction and here is how I'm doing.

  1. Upload file using fileUpload component in Flow.
  2. Get the uploaded file's ContentDocumentId using Get Records block
  3. Using this ContentDocumentId I'm getting the Content Version and storing it into a variable (type = Content Version Record), and passing it to my Apex Invocable Method.

Here comes my problem.

when I have the below code.

    public static List<String> test_getAccountIds(List<ContentVersion> Input) {
        List<String> accountIds = new List<String>();
        return accountIds;

It is returning Hi to my flow back with out any error. where as my other code(which is what I need).

    public static List<String> test_getAccountIds(List<ContentVersion> Input) {
        List<String> accountIds = new List<String>();
        System.debug('Content Data is '+Input[0].VersionData);
        EinsteinVision_Probability res;

        Blob fileBlob = Input[0].VersionData;
        EinsteinVision_PredictionService service = new EinsteinVision_PredictionService(myKey);
        EinsteinVision_Dataset[] datasets = service.getDatasets();
        for (EinsteinVision_Dataset dataset : datasets) {
            if (dataset.Name.equals('houses2')) {
                EinsteinVision_Model[] models = service.getModels(dataset);
                EinsteinVision_Model model = models.get(0);
                EinsteinVision_PredictionResult result = service.predictBlob(model.modelId, fileBlob, '');
                EinsteinVision_Probability probability = result.probabilities.get(0);
        System.debug('label is '+res.label);        

        return accountIds;

It gives me error as Unable to load Flow Definition. It doesn't even start the flow.

please let me know where am I going wrong and how can I fix this.


  • Seems "Run Flows" permission is missing for logged-in User's Profile.
    – Devendra
    Aug 7 '19 at 7:40

It's because Apex classes aren’t supported in the flows when access through Field Service Mobile App.

Here you can find more limitations in the document - https://help.salesforce.com/articleView?id=sf.mfs_flow_considerations.htm&type=5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.