Lightning Components in Flow! – Part 2

In Part 1 of Lightning Components in Flow, we looked at how to get a Lightning Component to show a list of records.  This post is an extension of Part 1, so since we’re building upon it, make sure to have Part 1 done.

In Part 2, we’re going to look at how to select records and send them back to the flow, create a Lightning App Page, and be able to use this form the Salesforce mobile app as well!  And all of this without any Apex!  That means that we can query records, select them, send them back to the Flow, without any test classes.  Now, with great power comes great responsibility, so make sure you sufficiently test your solution before you move it to production.

To start, we’re going to update our code for the Lightning Component, review what it means, and then build upon the Flow that we created.  We’re also going to use an almost unnoticed update from Summer 18 for Flow sObject Collection counting, a great example of the importance of it!  Ok, let’s get started!

Continue reading

Lightning Components in Flow!

In the Spring 18 release, Salesforce introduced the ability to show a Lightning Component inside a Flow screen.  It took me a while to be able to play around with this, but I am VERY excited for this!  This is not for first time Flow creators.  If this is your first time with Flows, look through some of the other posts on this blog in Learning Flow, Part 1.  But if you have some Flow background, get excited for Lightning Components in Flow screens!  Before we get started, I want to break down a few questions that you might have as I had them as well.

First Question:  Lightning Components mean code, why would we use them in a Flow?  That is correct, it is code.  I think of it like this.  Let’s take the example of an Account List.  The Lightning Component displays the Account List, however, you are controlling the logic to get the list in the Flow.  So, this means you’re not having to write code to create an account list or the logic, an admin controls that in the Flow, but the displaying of a list, Flows are not good at, so being able to send this to a Lightning Component to display is a lot easier than integrating with a Visualforce Page or writing everything in code.

Second Question:  Aren’t Lightning Components hard?  Lightning Components do mean code, but if you can put together a Flow, you can start to understand the logic for Lightning Components.  With something like showing a list of Accounts, the code required is very easy.  Salesforce has done a GREAT job expanding the base components for Lightning Components.  What’s a base component?  Think about the Dynamic Picklist Choice in Flows.  There would be a LOT of code to be able to get that done.  But Salesforce made it very easy and allows you to just select the Object and Field.  Base Components are similar, they are building blocks of Lightning Components, like the Dynamic Picklist Choice is in a Flow, and Salesforce takes care of the heavy code, so you just need to let them know a few key values to have their code run in the background.

Third Question:  Doesn’t this belong in a development blog?  NO!  I know you can do this!  As you’re learning Flow, you’re learning some of the logic of development.  This post will help you to expand just a little bit beyond Admin, to what some might call Adminvelopment, where you start to dabble in development.  The Lightning Component in this post is very lightweight, we are not going to have a controller or call apex, we are just going to display a list of Accounts and send that list from the Flow to the Lightning Component.

Ok, so where did this post come from?  For that, I have to thank Jocelyn Fennewald and Salesforce Saturday.  If you haven’t been to a Salesforce Saturday, you should attend.  What is it you ask?  A bunch of Salesforce people hanging out on Saturday and talking about Salesforce and maybe doing some trailhead.  Why should you go?  Because you never know what you’ll learn, where the conversation goes, or in this instance, what you’ll be able to help someone with and be inspired to learn something new.

So what is this post about?  Great question.  Jocelyn asked me if it was possible to use Flows to be able to create a way for a User to be able to look for referral accounts that match a User’s criteria.  Flow is great to be able to get the Account List based on a a few variables, but showing that list in Flow, well, that’s where the Lightning Components in a Flow screen come in handy!  What this post will help you learn is taking input from a User, finding a list of Accounts that match, and displaying those Accounts back to the User.  We’ll expand upon it in another post, being able to select records in the list and do something with them, but for this post, we’ll stick to the simple idea of displaying a list of Accounts. Continue reading

Accept button in Lightning List View

I saw in the Chicago Salesforce Saturday Trailblazer Community a post about the Accept button in Case Queue Lists not showing in lightning.  In case you’re not familiar, when you go to a queue on the Case object (or any object), there is a button on the List View that allows a User to Accept the Case (or other object, like Leads).

List-View-With-Accept-Button

This works in classic, but not lightning, and the post asked for people to vote for an idea for Salesforce to add it (you should go vote here).  The first thing I thought, this could be done with Flows!  So, here is the declarative solution (with just a very little Visualforce Page to launch our Flow) to help accomplish this in Lightning!

First, we need to create our Flow.   Continue reading

Requiring Fields at a Certain Opportunity Stage

Throughout the sales cycle, there may be certain fields that you would like to required by stage.  There are different ways to do this, for example changing record types by stage and having required fields or using validation rules to require fields if the stage is equal to a certain value.  Each way to do this has its own benefits and also its own negatives.  I had this need come up with a specific caveat, that it should be very easy for someone who is an admin be able to manage it with ease, as well as show users what fields would be required when the stage was selected.  My first thought was to use a Flow that would walk the users through the fields that would be required at that stage and at the end of the Flow, update the stage to the new value.  Although this sounded great, it would require someone to update a Flow to add new fields to the requirement.  Flows are great for requiring fields to be entered through required fields on a screen, but managing a change in a picklist value, with record types, as well as adding or removing required fields as the business dictates, makes a Flow a lot to manage.  Enter another level of Salesforce adminvelopment.  (Yes, I saw on the community someone posted, adminveloper, and adminvelopment is a byproduct of adminveloper.)
Continue reading

Send Quote Flow to Quote Line Item Flow – Learning Flow 4.A

This is part 4.A of the Learning Flow series, how to send Users to the Quote Line Item Flow from the Quote Entry Flow.  To start, open the Quote Entry Flow.

In the Palette, navigate to the FLOWS section.

Quote Entry Palette Flows Section

Click on the Quote Line Item Flow and drag it below the fcQuote Fast Create Element.  For the Name and Unique Name enter sfQLI for Sub-Flow Quote Line Item.  Since the Quote Line Item Flow is expecting the sovQuote sObject Variable, in the Target, click the drop down arrow, then click the arrow next to SOBJECT VARIABLES, then select sovQuote.  In the Source section, click the drop down arrow, then SOBJECT VARIABLES, then select sovQuote.

Quote Entry Flow To Quote Line Item Entry Sub Flow

Click 0n the Outputs section.  Click the trashcan to the right side, you won’t need to send any information back from the Quote Line Item Flow.

Quote Entry Flow Delete Line To Quote Line Item Entry

Click OK at the bottom.  Connect the fcQuote Fast Create Element to the sfQLI Quote Line Item Element.

Quote Entry Flow fcQuote To sfQLI

Save the Flow!

Quote Entry Flow v5

That’s it!  Congratulations!  You have sent your users from the Quote Entry Flow to the Quote Line Item Flow to create Quote Line Items!

Launch a Flow using Lightning Process Builder!

Some things just go together, like:
Peanut Butter and Jelly
Bread and Butter
Cinnamon and Sugar
Tom and Jerry
Thunder and Lightning

I’m sure you get the picture!  Now, I’m still warming up to the idea of calling Flows Thunder, but they go together with Lightning Process Builder just like Thunder and Lightning.  The same way that Lightning comes first and is followed by Thunder, Lightning Process Builder can run and kickoff a Flow as an output.  You get an update in a flash followed by a roar of business process!  Ok, enough with the symbolism!

This For The Community post has been brought to you by the world famous Salesforce Community, the Official: Salesforce Workflow Automation group!  Thanks @Jay Singh!

Jay came to me with a question:

Hey Rich,
Hope you are doing well! I know that you’re a Salesforce flownatic and I just happened to bump into something while creating a flow. I’m trying to get the Contact Roles from the Account module and try to get them to populate over to the Opportunity Contact Roles. So if a Contact Role gets created under the Account, it should appear automatically on the Opportunity’s contact roles. Do you think you can create a blog post for this particular flow. I will truly appreciate it.
Thanks in advance,
Jay Singh

As I told Jay on my initial response, kicking off workflow from the Account Contact Role doesn’t quite work with the Standard Salesforce Account Contact Roles.  A Custom Object can be used to kickoff workflow, so, upon his blessing to use a Custom Object, we’ll look at how to accomplish his question using Process Builder to launch the Flow.  He also said that:

it should update all Opportunities and should only include the Contacts that I am adding from the Contact Roles

Ok.  Custom Contact Role tied to the Account, when that is launched, add the new Contact Role as an Opportunity Contact role to every Opportunity on the Account, that’s our goal.  Let’s get started!

Continue reading

Create Approval Process in the Approval Process Flow – Learning Flow 3.B

With the Step Elements entered, it’s time to create the actual Flow.  Open the QLI Approval Process Flow.

Click on the Resources Tab in the left section and double click on SObject Variable.  Enter sovQLI as the Unique Name, the Input/Output Type as Input and Output, and the Object Type as QuoteLineItem.

Approval Process sovQLI

Click OK.  Click on Resources again and then double click on Formula.  For the Unique Name, enter fDiscount, Value Data Type as Number, Scale as 2, and the Formula should be, “{!sovQLI.UnitPrice}/{!sovQLI.List_Price__c}”.

Approval Process Discount Formula

Click OK.

You might be wondering, I see a {!sovQLI.ListPrice}.  Although this is true, since you are looking at the Quote Line Item before it is created, the {!sovQLI.ListPrice} hasn’t been entered yet.  It is also a field that is part of the Product.ListPrice, so it doesn’t translate very well with Flows.  Since you created the List_Price field earlier and assigned the List Price of the Price Book Entry, this does two things for you.  First (and most importantly), you can use the List_Price field in this Flow.  Second, it saves the history of the List Price, so if the List Price changes in the future, you’ll know what the List Price of the Quote Line Item was at the time of creation. Continue reading

Planning the Approval Process Visually – Learning Flow 3.A

Planning a Flow is a very important piece of creating Flows.  So far, you’ve been learning from what the posts tell you to do.  What about new Flows where you need to plan out a process?  Well, the Step Element will allow you to plan out your Flows!  You can’t activate a Flow with a Step element, but it will allow you to plan it out to make sure you are entering all the Flow steps needed to create a successful Flow!

Open the Quote Line Item Flow.  From the Palette, click on the Step Element in the Draft Tools section.  Drag it to the left of the aQRU Assignment Element.  Enter the Name and Unique Name as sAP for Step Approval Process.  Enter in the Description, This step will loop through the Quote Line Items to be able to see what level of Approval is Needed.

Quote Line Item sAP

Click OK.  Click on the Step Element in the Palette again and drag it above the sAP Step Element.  For the Name and Unique Name enter sAAP for Step Assign Approval Process.  For the Description enter, This will assign the proper approval on the Quote for Approval Processes. Continue reading

Create Quote Line Items, Update Quote – Learning Flow 2.C

Part 2.C of the Learning Flow series will allow you to create the Quote Line Items and Update the Quote.  To start, open the Quote Line Item Flow.

From the Palette, click 0n Fast Create and drag it to the right of the aQRU Assignment Element.  Enter the Name and Unique Name as fcQLI, for Fast Create Line Item, and set the Variable as socvQLI.

Quote Line Item Flow fcQLI

Click OK.  Connect the aQRU Assignment Element to the fcQLI Fast Create Element. Continue reading