Most of us are big fan of Flow but at the same time we miss a lot of obvious features like lookup fields, model dialogues etc. This blog post might bring excitement and motivation to give more attention and love to Flow.
Around 3 years back, I had written a post on how to create a lookup component in Flow. That solution was just a workaround without user friendly experience. Lets focus on better user interface today, In this post we will give lookup field ability to flow by simply reusing existing Lightning Component.
First and foremost, make sure you enable Enable Lightning runtime for flows by navigating to Workflow | Process Automation Settings , Otherwise flow would not run in classic runtime environment.
To use Lookup Component in Flow, only thing you have to do is download it from git repository and deploy it in your Salesforce Org.
Follow below steps to see working of Lightning Component in Flow
- Deploy Lightning Lookup Component in your org
- Create a new Flow
- Drag a Screen element in Canvas
- Add a new field of type Lightning Component in extension section as shown in below image
- Once Lightning Component field is dragged on canvas, set all applicable properties.
- We need to make sure design resource bundle in Lightning Component has all attribute mentioned which needs to be set by flow
- All attributes must be declared as global
- As shown in above image we have set various attributes of Lightning Component like
- which object to search
- which value to show
- which value to return
- how many records to display
- Which Icon to display
- Placeholder Text
- We also need to set output variable. We can return multiple variables from Lightning component. In this case, I would be returning only one variable containing ID of record selected
- Now, all we have to do is to create a new Screen and show selected record’s Id. That proves we can use Lightning Component, set attribute and read attributes from it.
Hope this blog post would open gates of innovation for your next Salesforce adventure.