How to: Build a Simple Salesforce Flow! (Salesforce Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey salesforce friends and welcome back to the channel my name is adam feusten and i'm an independent salesforce consultant based in the uk in today's video we're going to be looking at the flow designer and not just looking about what it does and its features we've got a different video for that which you could see in the description or at the end of the video in that video it actually compares the difference between the flow designer process builder and salesforce workflows so click on that video after this if you want to learn about what might be best for you to automate your business needs now what we're going to do in this video is we are going to do a follow me session yes we're going to actually together build a flow a very simple flow uh so that you've got the confidence at the end of the video to say hey i could design flows it will also give you the foundation to then do more advanced things which we could do in other tutorials follow me videos without further ado let's go straight into it and look at how we can build a simple flow using salesforce for low designer so in order to follow me as we build together um our first flow a simple flow um then what we need to do is log into your own developer org if you don't have an org of your own through your company like a sandbox or something now you could get a developer org for free if you didn't know already yes you simply click in the link in the description or you can type in developer.salesforce.com forward slash sign up and on this site you will see a form that you just simply fill in and click sign me up and hey presto bob's your mother's brother you've got your very own develop org and i recommend logging into that now so that you can then follow me for the rest of this tutorial as we build this flow i'm now gonna i have already logged into my developer org and clearly you you usually go on to your home screen or whatever splash screen that you enter first we're just gonna click on the little cog and setup so we're now going to go into the setup screen and we are going to type flow flows in the quick search because there's lots of flow options as you can see there flow category flows pros paused flow interviews but what we want is flows because this will take you if you click there to your flow designer list screen so we've got here all of these flows that are already being created so when did i create these well i've not created them because in fact these come with the developer org and in fact you can see some of these in this column are templates and in the previous video that we had where we look at the differences between flow and process builder and everything i did mention that one of the things that salesforce does to try and help you out is to pre-create and other third-party companies have done this create some flows as templates and what a template allows you to do is you could download them from the app exchange that's one key thing and then you clone it clone it and make your own version and then what you could do is clearly you'll need to tweak it and customize it slightly and if we could actually click into one of these outbound flow and look how complicated it is we've got a start assignment decision screen like what are all these things so although i'm a big fan of templates and it's great to go in there and just save time and tweak them what we're going to do is we're going to start from scratch because this is a beginner's tutorial and even when i started with flow i didn't really know what all of these things did so what we're going to do is we're going to close this and we're going to do new flow okay we've got different types of flows that you can create here we're going to be creating today a screenflow and this is where as you can see from the description guides the user through a business process that's launched from lightning pages experience cloud sites quick actions and more you've also got scheduled triggered flow so launch is the flow at a specific time frequency for each record in a batch this auto launch flow runs in the background you've also got auto launched flow no trigger so this is essentially gonna fire when invoked by apex processes rest api and more now this is an example of where you may have referenced a flow to fire in your process when we did a process builder um workflow that's the type of flow that you would create in that situation you've got record triggered flows launches when a record is created updated or deleted pretty straightforward or a platform event triggered flow a platform event is when there is an internal or usually an external message that is broadcast out and picked up by salesforce that will then launch the flow now an example of this that i've used before is like in the delivery company situation where there may have been a successful delivery on a third-party system it would then broadcast that message that salesforce if tuned in can then pick up and then it could trigger a flow on the back of it which might be to update certain records create some certain actions for other people to do something or launch the next stage in the provisioning process however what we're going to do is a screenflow for our very first flow experience so i'm going to click there and click next how do you want to start building so there is a new auto layout at the time of creating this video a beta version of this auto layout which will automatically click and and place the components um for you however we're going to do free form because i like to move things around how how i like on the screen now the example we're going to use is for trail trailhead itself and the example is this we're going to create our flow to capture information from a user and then we're going to query the salesforce org for a record that matches what the user enters now they're going to be entering first name last name if there is an existing record that matches the information that the user has entered then there is a decision and the decision is whether to update the existing record or create a new one and then the final thing is to create or update the record so all of those steps are what we're going to go through in the flow it's really quite quite simple but quite powerful when you actually just think about what you can then use this type of flow for and as we go on through the series you'll be able to expand your knowledge and complexity of what you're doing into these flows so let's start right so quick little look at the screen you can see that it's created our start component this comes as we create it and then in the toolbox this is the thing that we're going to start using to build uh the flow out we've got elements different interactions logics and data things oh what do those mean and then we've got manager and then you can create new resources ooh looks very complicated and strange but it's not it's very simple i'm gonna find out now by first going back to our example we're going to want the user to enter some contact information first name last name let's have a look at adding in this screen element here it's basically left click and drag as soon as we let go we then get our screen and what we're going to do we're going to create a label for it and we're going to put in here contact info screen great okay put description in there we want to see the header and footer let's just go straight up so now we've just created a screen fantastic it's actually just a template as you can tell for the moment let's just now connect the start to this next element so we want really the process to start from the screen when it loads up what we want to do is let's just first save it and we're going to create this is where we get the opportunity to create a name for this flow so we'll do new contact because spell so i just type the label as soon as i hit the tab button it will automatically populate the api name and as we are learning or may already know api names are the back system name for a field or a flow or a reference and there aren't any spaces you'll always see the same thing entered but within underscore you can put a description if you like doesn't really matter and if you click show advanced you'll see there's lots of other options that you can do but let's keep it simple let's just click save so we've got a screen we don't have any elements to capture the information yet but first what we need to do is to create a variable so what is a variable a variable is essentially going to be a table that we can store information that's entered from this screen okay and the variable will store the information in the session of the flow and then we can decide later on what to do with the information from that variable from that table in the background we can either write it to a record which is what we may do or we may update an existing record which is what we may also do as well depending on the decision later on so how do we create a variable or a table in the background to store the information that will be entered in the screen well click on manager in the toolbox then click new resource and when we click the resource type you can see we've got variable there so let's go straight and click there and in the api name we're going to create a contact i'm actually going to call it contact variable because i like to know what these references are as we go through this process of building the flow it'll make more sense when you see the reference later on data type right we want this to be an actual record so it could be a full record of information of all of the fields from a certain object and obviously it's the contact object is the thing that we want to be looking at and clearly because i've selected record it's same what object do you want this record to be created for so let's type in contact you can see all of the other contact objects but we just want the salesforce contact object and let's just click done great so now in my manager you'll see here a list of all of the resources that we create and you've seen or you can see here we've got the screen that we've created as a resource we've also got this variable which is a single record that we can create in a table okay so so next what we're going to do is we're going to create our elements that will allow the user to input the first name and the last name so to do that we're going to click on the screen double click on the screen and you can see here the screen has got nothing in it yet so we want to add in i'm gonna type in name so this is gonna allow us to put in some form elements and you can see here we've got a name card that's been added to the screen layout easy peasy drag and drop i absolutely love it so first let's now put an api name for this for this form and we're going to create we're going to call this contact name what we're going to do is go down to advanced and the reason for this is because we don't want the value to be a constant value one that we just hard code and we don't want it to be a resource you know a resource something like a variable you know like if we search for a record and then we pre-populate we're not pre-populating this will be blank when the screen loads and then we're allowing the user to input the information into the form so we're going to go down to advanced instead and we're going to manually assign the variables and what that allows us to do is it allows us to choose which fields to display the first name the last name etc etc and what we're interested in is putting in the first name so what we need to do or what we're trying to do with this again because this is where drawing it out makes things a bit easier we've got a name card with first and last name as two field entries that we want the user to type into but what do you do with that text that's been entered in well we want to store it in our variable in our table in the background so that we can then later do a search in the database using that table of information to see if there's a contact record that already exists so we want to make sure that the first name field is going when we type it in is going to save it in our contact variable table so when i click in the box there you'll see i have lots of different options but what we want is this contact variable that we created earlier on if we click on the arrow there it then takes us to the object record fields and clearly we could just type start typing here first this is the name of the field that we want first name great so now when we type a first name in in the form the text that the user enters will save in our contact variable table in the record or field of the record first name fantastic we now want to do last name so we do the same again click into the box click the contact variable resource that we created the table that will store the values and instead of scrolling through we could just type last last name there we go fantastic we then click done and as always click save just so that it's uh making sure that if my internet goes i've still got it there fantastic so now that has been saved what we also need to add in is a pick list for a list of accounts in the org because what we want the user to do is to write in a first name and a last name but if it just uses those two pieces of information to search for all the contacts in your org there could be a lot of john smith's or mary contraries or whatever names might be common uh for you in your database so we're gonna add in another pick list that the user could select and that will be a list of accounts in order to do that we click new resource because what we want to do is create a table of data and the data that's going to be returned into this table that will be stored in the background and used as the the labels and information in our pick list we need to search and create a resource for that to be held into so the resource type if we just click in here we've got obviously the variable we created earlier but what we can do is actually create a record choice set if we call this account pick list again trying to make it quite descriptive as a name it's an api name so it's taking the space out automatically if i then click in my objects i'm then going to say well this because it's quite a confusing name for this record choice set but if you actually break it down you're looking at records and you and it's the set of records are going to be a bunch of choices that you can use in the pick list that's probably a really bad explanation essentially a table of data and therefore i'm going to pick the objects that i want this data to pull from account that's what we're looking at as soon as i click the object hey presto i then have the ability to filter the account records and sort the account records and configure each choice and store more field values wow okay let's break it down step by step first thing filter account records lots of options what we want is no filtering we want a list of all the accounts in the org you can also see which gives you inspiration of what you can do when you create your own flows put them in ascending descending order and maximum number of choices as well so you're not seeing you know thousands if there are in your org um configure each choice so what does this mean for each record that meets the filter conditions and in this case we're showing all the records at the flow creates a choice using values from the record so we're looking at the account object and therefore we can choose a a field to show as the choice or pickles drop down label as in you know what the names that i won't display and we can also choose what we're going to have as the value so what's the difference between a label and a value so the label is what we see the value is what is used in the background okay right so first let's click in this box the choice label now we want to show in the pick list the account names [Music] let's try typing name there we go account name so that's going to be my choice label so in order to connect this new contacts that we might create with the account we can't use the account name because there could be lots of names we of course yes you guessed it need the id of the account stored in this table or stored in this this value selection so if we then type id we can see again lots of id fields but this is the one we want account id just named id and there we go so when i click my pick list i'll see the list of account names but when i click on acme limited as an account name it won't store the account name itself it will store the id of the account that i can then use later on to connect to my contacts that i create in my create new record action that i'll do later on so we're all thinking ahead again draw this all out on paper helps guide you through this process and the final section that we've got here is store more account field values so what's that essentially telling us it's saying okay great you've selected an account we've we've got and captured in this pick list field the value of the id of the account what do you want us to do with it so what we want is to store that account id in our contact variable table that table that we're creating that will store the first name and last name that the user enters we also want to store the account id that the user selects from the pick list in order to do that we first select the field from the account record that we've selected again we want the id and then once we've selected that we then choose where we want to store that account id like we said the contact variable table that we created earlier and then on that contact id or that sorry that contact object we see all of the fields you can see at the top we don't need to type it account id so now when i create or if i create a new contact it will put the account id in that contact object record field account id brilliant done save so what have we done so far we have created a screen we've got a card where we have first name last name but we haven't got that pick list value there so we need to we need to create that now so creating that picklist value that we want to use to display all the account names is super easy we've double clicked into the screen element once we've done that we can see the name card that we created earlier the first name last name go into our component section you can scroll down and see all the different types but we're gonna create a not dependent not a multi-slit select but a pick list just drag that in there we go so we'll first create a label for it something yeah you could call it whatever you want but let's if we could type properly account list let's call it that automatically creates the api name we're going to keep the data type as text because it's going to display the name of the account and then obviously i'm going to store the id later on but for now let's just there you go create a text default value no default value you can't really do it on this type it doesn't seem now choices we want to display the the record choice set table that is going to return all of those account records and we could just simply click on the choice we can see already there that we have the ability to select a record choice set we've already created one account pick list do it fantastic click send done and save what we're going to do now is we're going to actually stay in this screen we're going to add another level of user interaction and complexity we're going to create and add a toggle what is a toggle wobble wobble toggle toggle it's actually just a little switch that you can put on off true false kind of like a check box but a toggle right what are we gonna call this thing update toggle great but what's the label gonna be now i want this to be quite descriptive and here's one i saved earlier on the clipboard if this contact already exists update the existing record that's the name of this toggle and you'll see that in the ui when we run it why is it called this clearly if it turns out that when we put our first and last name in and it runs and it finds a contact in that account already existing on the account what we're doing is we're allowing the user to make a decision we're allowing them to say yes when we move to the next screen or next phase or the next action i want you to update the contact record that's already there i don't want to create duplicates however if they turn that toggle off and they want to create a new one a new record we want to empower allow the user to do that so that's the complexity that we're going to do active label so what do those actually mean active label disabled inactive label and value active label essentially means when you've turned the toggle on what do you want to display is the the kind of the value that's that's displayed there to show that it's active and what we're gonna put here is update existing so when it's active when they turn the toggle on it means yeah yeah yeah if you find an existing record we'll update the existing one we're going to skip the disabled one but if it goes to inactive as in they've gone false what we want to do is we're going to use a variable or a value elsewhere in the table we're going to put create new contact create new content okay so it's very clear what's going to happen if they find an existing record but turn the toggle off it's going to create new contacts at the end of that and in the other part of this video we were going to the advanced section and manual assigning variables let's just leave that unchecked we don't really need to faff around without that's us that's all we need to do is just add this toggle with those settings done then click save as we always do now here's an exciting bit we've not finished yet all we've done is create a screen but what we're going to do is we're going to run this to see what it looks like exciting right look at this wow we've got new contact screen element first name you can see i've created some already let's do daffy duck there we go and then i've got here the list of accounts that are on this uh this org fantastic let's just click on one of those and then we've got a toggle it's inactive so we're going to create a new contact if it finds um an existing record if i click the toggle it says oh well if you find an exiting record that matches the name daffy duck in dickinson plc then update the existing record finish what does it do nothing it just cycles back to the beginning of that flow it's because we haven't got any other actions in the back of this let's do that now so now we've run that and we can see that it's all working it looks great we now need to do the logic we now need to do something on the back of it so we've entered in the first thing we've entered in the last name we've selected an account record we've then said whether we want to create or update a record well first what we need to do is first search the system and find if the contact actually exists or not so how do we do that we are going to do a get records function let's drag that in there we're going to put a label in find a match good enough name as any um we're going to get records of the object contact that's what we're searching easy peasy we then see this blow out so we want to filter records do we want to filter records yes we do because we don't want to see all records or brought all records back we want to find a specific record and that would have to be one that matches the first name and the last name so let's type in first name equals what value well we want the value from the from the screen that's been entered well when the user enters the value in the screen it's stored in our contact variable table don't forget so that's where this comes useful again this this variable that we created contact variable click on there we then get a list of the fields from the contact object and we of course want the first name that is being stored we also want to search for the last name there we are equals again the last name from our contact variable so we just type in last aim there we go and the logic is set conditions are met and or or custom logic we want the and we want it to be first name equals this and last name equals that from our contact variable table coolio let's just click done awesome so now we've created that screen with the customer entering the information it's now going to go and get the records from the database that match the information that we've put in there fantastic next step is to create a decision branch the two options that we've got do we want to create a record a new contact record or do we do we want to update a contact record so how do we create those two different paths decision element let's drag that one in and i'm going to stick it there there we go it appears i can put a label in for it update or create that's what we can call it now you can see new outcome has been created there it's called new outcome because we haven't put a label there we're going to put update existing so once we click that creates the api name you'll see that this outcome is updated to the label we've created update existing so that's going to be our first path we want to update an existing record so in order to force it down this update existing record path we want to make sure that the conditions are met we're going to create two conditions here first one the toggle so if this toggle so i'm going to create it there if the toggle value equals on so they want to update an existing record that basically means they it will be set as true so where is true in this so we've actually got a global constant and global constants are basically global meaning anywhere in salesforce there is a constant fixed value and that in this case could be a true or false so what we're going to do is we're going to click true which is equivalent to checked or yes so they've gone to the toggle they've switched it on made it active gone yes i want to update the record fantastic in this second condition we want to go to that get record function that variable which we called find a match click on there we don't need to select a certain field because what we're going to do is we're going to actually choose the operator is null in other words there's nothing in the table if we put there's nothing in the table false meaning there is something in that table it's found a record there's values in there first name second name etc etc then we know for sure between those two that we are going to be updating an existing record and not just updating it but one actually exists in the second condition default outcome it's called default because we've got not given it a name what's the second path that we can go down update an existing record or create a new record so let's call it that create new contact click away there we go we've got no conditions because we're gonna do the action of creating a record so this is the default click done hey presto it's there let's link the nodes together click save now we've created that decision path one path leading to update record the other one to create record let's now actually build those elements in so let's drag the create record element into the flow screen let's put a label for this create new contact there we go how many records you want to create just the one all values from a record contact variable that's the table again that has the information stored of the first name and last name that the user has entered and it's also got the account id stored there from the pick list that we've created so we want it created from that contact variable let's click done and connect the node in once we connect the node from the decision tree it's saying oh which path is this element gonna be connected to well it's a create record function so we want to use the default path outcome or the one that we renamed as create new contact done look at that we have got ourselves a contact new record outcome taking us down to create record element fantastic the next thing we need to do is of course go down the other path which is update the existing record now before we just go and drag that update record first we're going to go and add an assignment and logic element what does that mean well don't forget the table that we've created we've got the last name and first name and last name we've also got the pick list that we selected the account from but in this situation it's found an existing contact record so what we want to do is update that existing contact record and in order to do that we need the id of the contact record it found in the get records function in order to store that contact id in our variable our contact variable table to then create or update sorry that record let's just drag the assignment in we can then we can then call this set contact id because that's what we're going to do and we're going to use the variable that is going to be modified so first we select the table our contact variable table that is holding all the information that will then write and update the existing contact record in that table we want the contact id it's actually just id there we go contact id is just id because we're in the contact object i want it to equal the variable value as in the value that's found from the find a match get records table when it searched for those contact records and going oh i found one first and last name it matches and then again we want the id the contact id of the record it found just to recap this is a new assignment it's going to assign a value for the contact id of that table so everything is stored there it knows exactly which contact record to go to to update the values of done i can then drag this decision node it's only got one left so i don't need to choose of course the only one remaining is update existing and when it goes down that path it's going to go all right okay the contact id that we found from our search we're going to populate in that contact variable table now that contact variable table has got all the information in the background what do we do with it well we want to update a record of the record update existing contact record i have quite long names for these don't i but i like to be quite descriptive we can see here that use the ids and all the field values from a record or record collection that's exactly what we want to do we want to use the values from that contact variable table let's click that and done final thing we need to do is drag that node into there and click save so we have actually finished it amazing before you started this you probably thought what is a flow too complicated i can't do it but by following me on the screen you've been able to do a very simple flow and then that's the foundation to try out new things even go to the other videos that we'll look at later on to create more complex flows yourselves now we can click run or we can click debug debug if we click that debug is quite useful because what it does if we just click run on there it will show you what happens in the right and tells you really good if you've kind of forgot something or not done it right it will then tell you what's gone wrong i'll actually just give you a log of everything that you've been doing so let's now put in my daffy duck actually that's daffy is his first name duck clearly is his surname and i'm gonna choose dickinson plc now when i ran this before it wasn't writing or creating any records so this shouldn't exist so i want to create new contacts because i know it doesn't exist all done it's finished what happened so i can look at the debug log on the right and see that all of the little things that i've done what i can do is go to my home screen and i can search daffy duck and you can see there is create the contact hey daffy duck has been created in my dickinson plc account cool well hopefully you found this video useful you've created your own flow well done congratulations you're on the first steps to being more advanced in salesforce and more confident if you want to go a few steps back and look at the process builder and do a follow me session where together we can build a process from scratch well click one of the thumbnails here to go to that video there is another video that will show you the comparison between the flow designer process builder and salesforce workflows so you can actually just judge for yourself which one is going to be best for the automation need or the logic that you want to do in the system and finally please click the subscribe button and the notification bell just so that automatically you'll get these videos coming up in your feed because we're going to publish one every week with new stuff coming up all the time and also please please please engage with me tell me what you found useful in these videos or in fact tell me if you want a certain video created to try and make your sales force life much much easier more productive and happier until then may the salesforce be with you
Info
Channel: Adam Foyston
Views: 6,218
Rating: undefined out of 5
Keywords: flows in salesforce lightning, salesforce flow, flows in salesforce, salesforce, trailhead, salesforce tutorial, no code, Salesforce, Salesforce Flow Designer, Process Automation, CRM, Consultants, Administrators, Developers, automation, salesforce demo, flow builder salesforce
Id: QV0NT08W7OM
Channel Id: undefined
Length: 37min 43sec (2263 seconds)
Published: Tue Apr 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.