Sample Flow:
accountId Input Variable:
accountName Output Variable:
Sample Code:
Map < String, Object > flowParams = new Map < String, Object >();
flowParams.put( 'accountId', '0013t00002XXRyDAAX' );
Flow.Interview.Account_Auto_Launched_Flow myFlow = new Flow.Interview.Account_Auto_Launched_Flow( flowParams );
myFlow.start();
String accName = ( String ) myFlow.getvariableValue( 'accountName' );
System.debug( 'Account Name is ' + accName );
Output: