1

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.

@InvocableMethod
    public static List<String> test_getAccountIds(List<ContentVersion> Input) {
        List<String> accountIds = new List<String>();
        accountIds.add('Hi');
        return accountIds;
    }

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

@InvocableMethod
    public static List<String> test_getAccountIds(List<ContentVersion> Input) {
        List<String> accountIds = new List<String>();
        System.debug('Content Data is '+Input[0].VersionData);
        System.debug(Input.size());
        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) {
            System.debug('dataset.Name'+dataset.Name);
            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);
                res=probability;
            }
        }
        System.debug('label is '+res.label);        

        accountIds.add(res.label);
        //System.debug(accountIds);
        System.debug(accountIds.size());
        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.

Thanks

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

Your Answer

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

Browse other questions tagged or ask your own question.