So instead of inserting directly using apex a new record of which the fields are being filled in a form by the user ! I want to do that using a FLOW, so I want to fill the FLOW by the form values and launch it! So far I am passing the values from the client side to Apex, and then I want to pass those values to the FLOW !

my apex function looks like this:

    public static void createContactFormRecord(Contact_form__c contactFormRecord) {
        if (contactFormRecord != null) {
            // create security boundary, only use these fields.
            Contact_form__c newContactForm = new Contact_form__c();
            // Subject__c does not exist!
            newContactForm.Email__c = contactFormRecord.Email__c;
            newContactForm.First_name__c = contactFormRecord.First_name__c;
            newContactForm.Last_name__c = contactFormRecord.Last_name__c;
            newContactForm.Order__c = contactFormRecord.Order__c;
            newContactForm.Comment__c = contactFormRecord.Comment__c;
            newContactForm.Phone__c = contactFormRecord.Phone__c;
            newContactForm.Reason_1__c = contactFormRecord.Reason_1__c;
            newContactForm.Reason_2__c = contactFormRecord.Reason_2__c;
            //newContactForm.Reason_3__c = contactFormRecord.Reason_3__c;
            newContactForm.Country__c = contactFormRecord.Country__c;
            newContactForm.Language__c = contactFormRecord.Language__c;
            Map<String, Object> myMap = new Map<String, Object>();
            // this is where I am supposed to fill the map object that i will pass to the the flow

            Flow.Interview.Create_ContactForm myFlow = new Flow.Interview.Create_ContactForm(new Map<String, Object>());
    return null;

And the flow in salesforce looks to something like this:

enter image description here

I did some googling but couldn't find any accurate help any thoughts developers any help would be appreciated thank you !


You have almost done the needed work. You just need to fill in the map you instantiated and pass it as a constructor parameter.

Map<String, Object> myMap = new Map<String, Object>();
// this is where I am supposed to fill the map object that i will pass to the the flow
myMap.put( 'Comment', contactFormRecord.Comment__c ); //Key is the name of your variable from the flow 
myMap.put( 'Country', contactFormRecord.Country__c);
Flow.Interview.Create_ContactForm myFlow = new Flow.Interview.Create_ContactForm( myMap );

Please refer to this help page for more information about Interview class, where you can find an example:

Interview Created Statically for a Local Flow
  Map<String, Object> inputs = new Map<String, Object>();
  inputs.put('AccountID', myAccount);
  inputs.put('OpportunityID', myOppty);
  Flow.Interview.Calculate_discounts myFlow = 
    new Flow.Interview.Calculate_discounts(inputs);

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.