Hello friends, In this post, I will let you know the process of passing picklist value from flow to apex handler. This post may be long so please follow each step carefully.

Pass picklist value from lightning lightning flow to apex

Step 1: First create a apex class (FlowHandler) with following markup.

FlowHandler.apxc

 public class FlowHandler {
public class ParamRequest{
@InvocableVariable
public string picklistOption;
}

@InvocableMethod(label='Flow Handler') // This label will display in flow to select apex class
public static void MyMethod(List<ParamRequest> sParam) {
System.debug('Selected picklistOption '+sParam[0].picklistOption);

}
}

Step 2: Navigate to Setup | Process Automation | Flows  and click on New Flow button.

Step 3: Select Screen Flow from flow template and click on Next button.

Step 4: Select Auto-Layout for automatically placements of elements on the canvas. For manual placements you can go for Freeform.


 Step 5:
Click on Plus icon.

Step 6: Click on Screen element. 

Step 7: Enter screen element Label and API name as per below image.

Step 8: Drag Picklist element inside screen element and set the picklist Label and API name as per below image.

Step 9: Scroll down in picklist setting and click inside Choice textbox then click on New Resource option. In new resource window select Choice as resource type.

Step 10: Enter the choice API name, Choice Label, Data Type and Value as per below image then hit Done button.

 Step 11: Repeat Step 10 to add second option in picklist after clicking Add Choice button then hit Done button on screen element.


Step 12: Now again click on Plus icon and select Action element. In New Action window select Uncategorized from left side pallet then select apex class (FlowHandler) in Action textbox. Enter Label, API name and inside Set Input Values section select picklist that we created Step 8. Hit Done button.


Step 13: Save flow and click on Run button to test the flow.

Step 14: Pick option from picklist and click on Next button to see the output in developer console log.

Output:

 

Hope you like this post, for any feedback or suggestions please feel free to comment. I would appreciate your feedback and suggestions.
Thank you.