0

I am trying to call a flow from apex. The apex class passes the Phone number of a contact to the flow and expects the contactId. Whenever I auto launch the flow using apex, I am not able to get the result, it returns an empty string even for a valid contact. However, when I use screen elements and set the same input, it returns the appropriate results. It just doesn't work when called from apex.

public class GetContact {   
    public static void start(String contactPhone) {                
        Map<String, Object> params = new Map<String, Object>();

        params.put('inputContactPhone', contactPhone);

        Flow.Interview.GetContact newFlow;

        newFlow = new Flow.Interview.GetContact(params);

        newFlow.start(); 

       //Rest of the code          
    }
}

In my flow, I just have an assignment block which takes the input from the apex code and assigns it to flow variable and a record lookup block that tries to fetch the contactId using the phone number.

0

Since i had not used (SeeAllData=true) Annotation in my TestClass, i was not able to access the data records. This is the reason that i received a null value for all my queries. Its mentioned in the apex developer guide,somehow i did not notice that.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_seealldata_using.htm

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.