Parsing Stuff with Flows (Part 2)

Standard

In part 1, I built out the change of thinking that we will need in this blog post to amp up our data parsing using flows. For a quick recap:

  1. The scenario is that we have questions and answers
  2. The flow does the parsing by treating questions as keys
  3. We are using a text input in a flow to simulate the action of a user copy / pasting question answers into a text field

As demonstrated in the last post, this works within the context of a flow, but now in this post, I am going to show you how to apply this. To demonstrate this, I am going to add a text box onto both the lead record and contact record to receive data, two text boxes that will receive the parsed answers and a checkbox to display an error state. To launch this flow I am going to use a process builder on the lead and contact.

The process builder functionality is the same on leads and contacts. The ID will be passed to a variable in your flow. This variable is used by the flow to determine which update action to use. The input is also passed over to a variable. This does mean that for those following along at home that they will need to change their formulas from using a text box to using the formula. This is in addition to the changes needed to make it an autolaunched flow (Removing screens, etc).

Now, I did mention the whole error checking thing in my last post, so baked that in as well. The key here is to first check for errors THEN figure out which record needs to be flagged.

The end result will be something like this:

with error check

So, how does this work? Fan-Tas-Tic. With just two processes and a flow, I am able to do parsing on each record.

end results

Adding this parsing logic to a new record would just be adding a new process and updating your flow. This is a great example of how you can use flows to harness the power of apex with the ease and lower support cost of configuration.

Now, this is setup for a pretty specific example…A rep would be pasting in data from an external source, but the methodology would be the same as long as you had a source of text. So, with tweeking you could use this on fun stuff like inbound emails or maybe even chatter posts!

How does it feel? Not quite like this, but close.

I have the power.gif

 

 

Parsing Stuff with Flows (Part 1)

Standard

Salesforce is really good at a lot of things, but digesting or looking for bits of data within large chunks of text is not a particular strong suite, though to be fair, not may systems can brag about how awesome it’s parsing ability is. I was thinking about this subject since there seems to be two camps, the configuration camp backing workflows and formulas and the code camp backing apex. I am going to propose a bit different way…an adminveloper way.

To start with, we are going to use flows for this. The reason I am going to use a flow is that I want this as object agnostic as possible and I don’t want to be constrained by any of the formulaic limitations (Looking at you char limit of related formulas!). Using a flow will also let me do some fun stuff later on (cough, next blog post, cough), but the biggest reason I want to use flows is the variables.

But, before we get into the nuts and bolts, I need to first talk about how I changed my thinking about this. Let’s say I have some questions in a text field and I want to parse out the answers to these questions. In the past, I might have tried to hard code in some right / left functions, but that is rigid and leads to stuff like “Answer this question in less than 255 char…”, ugh. Instead of trying to build out left / right stuff that ignores questions, you need to think of questions as keys in your document. They are a unique set of text / numbers that should only occur once in your doc, and because we are thinking like this, we can use the FIND function to locate their specific points within the text.

For testing purposes, I am just building out a basic flow with a long text input field that will be parsed.

The flow will look for my “keys” (AKA, questions) and determine how much distance (in char) between the LAST CHAR of a question and the FIRST CHAR of the next question. For the last question, we are going to use a footer as the marker (“Thanks for your time!”).

I am going to do this with a series of formulas, one for each question:

  1. Find out how long the whole piece of text is (This is just a LEN(your text here), not going to expand it out.)
  2. Find out where each question ends
  3. Find out how long each answer is
  4. Build out the answer

Formula number two is finding out where the questions ends. To do this, you use the “find” function, looking for the variable within your text. Now, you need to ADD to this the length of the question since you are looking for the END of the question and FIND returns the char location. Here is what the formula looks like:

find({!varQuestion1},{!Enter_Sample_Text_Here})+len({!varQuestion1})

Now that we know where the first question ends, we need to find out how long the answer is. We do this by subtracting the value from the first formula from where the value of where the next question (or text) starts. I did it this way, though you could have also just used a new find function. In a nutshell, at this point, we have determined that the end of question 1 is X and the start of question 2 is Y and that the answer is Y-X long.

({!FindQuestion2}-len({!varQuestion2}))-{!FindQuestion1}

Knowing this, we are going to go ahead and build out the formula that strips out the answer from the text. It is going to use a combination of left and right functions. We are essentially grabbing all text to the RIGHT of the end of question1 and then taking just LEFT text of that in the length of the Answer

left(
right({!Enter_Sample_Text_Here},{!GetLen}-{!FindQuestion1}),{!Question1Length}-1)

For the last question, you would just use the footer location:

{!FindQuestion4}-{!FindFooter}

FindFooter = find(“Thanks for your time!”,{!Enter_Sample_Text_Here})

This is how this function would look just running it from a flow:

So yeah, with just a few formulas inside of a flow, parsing can be easy – peasy if you adjust your thinking. Now, before I leave you all hanging for part 2 of this blog post, let’s also take a look at something fun. What happens if someone starts to monkey with the questions? Well, through a little bippity boppity boo we can do something about it, without any more formulas. See we are using the FIND function already in the first formula that finds the end point of the question…and if the find function doesn’t get a match it returns a zero, thus, we know that if the formula that finds the end point of a question returns the length of the key variable something is off. This can be done with just a decision!

Alrighty, that is it for now! Part 2 is going to expand on this FUNctionalitye even more, so stay tuned!
As always, let me know if there are any questions / comments / or you just want to buy me coffee and pick my brain.

 

 

Clone User – Lightning Awesome

Standard

Way back in the old tyme days of 2014, Salesforce was running a contest called #Salesforce1selfie. I decided to try porting my clone user flow (Spoiler, totally worked) but that isn’t the fun part. The fun part was using flows for MY gain!

marsha marsha marsha

Andrew, Andrew Andrew

But, that was 2014 and it is now 2017 and Lightning is now the cool kid on the block. So, going to take a revisit to the old clone the user app and see about making it more 2017 than 2014.

First things first, I had to recreate the clone user flow. Surprisingly enough, you really just need to follow my previous mentioned post and you are good to go. You gotta make sure to activate it though.

The real change is on the page layout. The easiest way to to do this is to go to a user record, click on the gear icon and then click on edit page. Sorry for the crappy screenshot, new computer.

user click on gear.PNG

Now that you are on the page edit layout (I am sure there is a better technical name!), I would do the following, though the ONLY required part is adding a flow widget.

  1. Add in a tab widget.
    tabs
  2. Reorder the tab widget so that related is on the right.
    swap done
  3. Rename details tab to your variation of clone user.
    renamed section
  4. Drag a flow widget to that tab.
    flow widget
  5. Set the flow to be your clone user flow and the variable to be the record id.
    pass variable

Go ahead and save the changes and make sure it is set to be the default of whatever you have setup. Click into a user profile and behold, the tab that says Clone User!

user page

Click on that tab and WOOT, the user ID from the source is passed.

clone user on page.PNG

The rest is literal history. You don’t even need to really update the original flow!

Questions, comments – Let me know!

 

andrew

Smarter Text in Flows

Standard

As Salesforce admins, I hope you have figured out that Flows can make your system super smart. I think this is a smart little hack to flows that can help make them even smarter!

Hopefully not this smart

Here is the setup. You have a flow and in this flow there is some data that is stored in variables. Because this data wants to go forth and adventure, you might use a text template to put some, well, text around those variables so that it makes sense. The text template would then be used in an email alert (just for example).

The thing is, as we all know, the minute you get the text of ANYTHING dialed in, someone asks for it to change. So, into the flow you go, modify the text template, save a new version, etc, etc, etc.

But, what if there was a better way? That question was rhetorical, since there totally is a better way.

For this blog example, I am just going to have a two screens, one as a starting point and a final screen that will substitute for the above mentioned email alert.

flow overview

No clever caption for this

Notice, there is NO text templates in this flow.

Look - No Text Templates

But, the end screen has all this text? WHAAAT?

Final Product

And, just to prove I am not pulling a fast one, here is what that field looks like…it is just variables.

and just to prove...

Instead of using a text template, I am using a text field on an object. The trick here is that you have to enter the variable technical names (Curly brackets, exclamation points) into the text field. This text field is then pulled in the flow via the record look up and will accept the values from the variables.

Really, this is acting JUST LIKE A TEXT TEMPLATE, but with the advantage being that if you want to modify the verbiage you don’t have to go through the modify / save as / activate cycle.

But, we can make this EVEN BETTER! Obviously, having to enter the technical variable name limits how many people can actually use this. But, by adding a bunch of code…LOL, just kidding. We are going to build out a formula field instead. You have to do some gymnastics to get the formatting to work, but once you have it built out, you now have a formula that will show up on the actual records itself and used just like the text field above.

formula           formula on screen

And, the end result is the same!

automagical results

 

so, what do you all think? useful? not? any suggestions? I even take requests if there is a weird question (about salesforce) you might have.

 

You know who likes innovating? I like innovating.

Standard

You know who likes innovating? I like innovating.

This-Guy-Jim-Halpert-The-Office.gif

NOTE – Not actual salesforce admin writing blog.

Thus, when I saw that Salesforce Seattle was hosting an app innovation workshop, I decided to sign up.

The class was pretty neat, the group brought out a SE that showed us how to build out some apps and how the new lightning interface was going to make app building EPIC.

And then, just like that, it was our turn to build an app. We separated out into teams and planned (And ate tacos!). We had 2 hours to build out an app that was mobile, had some business value and used the lightning interface….and had a clever name.

No problem.jpg

NOTE – Not actual blog writer.

My team (Fairy Godmothers) decided to tackle a problem that is all too familiar to sales teams (and ghost busters) …you know what I am going to say here, “Who ya Gonna Call”?

ghostbusters6.jpg

NOTE – Not actual team photo

Being that I have never done sales, this is all anecdotal, but the nods of both the AE’s and SE’s in the room told me that I was on to something. I have noticed that a salesperson will get on a call that should not require a technical resource and then BAM! The potential customer brings a nerd along and the hard questions start to flow. The salesperson then is left scrambling for resources, vowing to never let this happen again! The next call the salesperson goes on they invite the SE and the SE just listens in and play angry birds. On a side note, I once worked at a large company that the meetings would get so large because of this phenomenon, it would take like 10 minutes to do introductions.

Being that we only had two hours, I decided to keep this simple. No custom objects, just using the functionality Benioff gave us! So flows were used…because…well…I love flows. But seriously, using flows also gives me the ability to create advanced, code like (Dare i say, low / no code?) functionality without worrying about things like UI and, well, code.

The flow itself is not anything spectacular (two hours!). Screen Shot 2016-12-21 at 10.17.40 AM.pngIf it is launched via the app, it just pulls up a list of the users open opps. The user selects one and then is presented with a list of current active users and a selection around communication methods. Selecting email will send an email, but selecting text sends out an email using the email to phone number “hack” (is it a hack any more after it has been around as long as this one?).

However, there is one bit of fun that I want to call out (as I have done before). I pass a variable to the flow which is then analyzed. This variable is ONLY populated when a flow is launched from a record, so if this variable is populated, we would know that the flow started from a specific record. By doing this, I can build out decisions that adjust the functionality. In this case, I have two start screens, one for when the flow is launched via the app (and shows all opps) and one for when it is launched via record (and just goes right to the fairy godmother selection).

Screen Shot 2016-12-20 at 9.15.09 AM.png

“And then the running back goes around the TE..BOOM!”

By doing this, you can avoid using two flows what is essentially the same functionality.

To get this working on the individual record, you have to use a visualforce page

NOOOOO.jpeg

NOTE – this is the blog author writing code (just kidding).

because the button URL hack just won’t work as expected. You can place a flow on the record page layout, but I wasn’t able to figure out how to pass a value. If you know now, shoot me a tweet (@jok3r4o2) OR send me a message through the success community. If you are local to Bellevue, I will buy you a coffee.
Anyways, not a huge deal to create a VF page. I have documented it a few times AND by doing a VF page on a button, it allowed me to make it mobile really easy by just adding an action!

<apex:page standardController=”Opportunity” showHeader=”false” sidebar=”false” >
<flow:interview name=”life_ring”>
<apex:param name=”varSourceOppId” value=”{!Opportunity.Id}”/>
</flow:interview>
</apex:page>

Alrighty, so that is the nuts and bolts of my two-hour build. Pretty dang happy with this app and will probably put into production. But, how I would I make it better? Well, cue the Scooby Doo transition!

giphy

 

  • Show users that are logged-in. I found a really cool table when building out the flow called “AuthSession”. https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_authsession.htm This is the table that shows who is logged in and how. Now, it wouldn’t be as straightforward as just using this as a dynamic lookup, but still, the idea that you could see who was logged in before you contacted them is pretty great.
  • Finding Relevant Users. Using the power of flows, we could do some data crunching to build out a profile of a specific opp (product, competitor, etc…) and then use this information to pull only fairy godmothers who have had experience in these areas.
  • Gamify! This type of app lends itself to gamification. I would have built this out so that Fairy Godmothers got credit or went up a lead board (AKA, Dashboard) for the help that they do. If you go down the gamification path, brush up on Maslow’s Heirarchy of Needs to figure out how to reward employees.
  • Communicate in multiple ways. I am using email and text, but it would be a good next step to also post in chatter. You could also use a service like Zapier or IFTTT to post to slack.

And that my friends is that! As I said, be sure to check out an app innovation workshop. I came away excited for Lightning UI and all the neat things it can do along with a great app idea and a couple Starbucks Gift cards.

As always, did I miss anything? Do you have a great idea for an app and just need a bit of help? Find me on success.salesforce.com and drop me a line!

Quotable Quotes for 500 or how I learned to love SFDC CPQ.

Standard

Boy Howdy! It has certainly been a while since I have posted here! Hope everyone was missing me. I have a particularly interesting blog post for you all today…it explains my truancy AND talks about some neat stuff I have been doing!

51kdgksaudl

But, first, we have to go back in time to August 1…You see, on August 1, 2016, I made the jump from where I was to a funky little place called Auth0. There I was, admiring a shiny new macbook and an almost pure like driven snow org when my boss interrupted my revelry by saying:”Hey, glad to have you, we just got Steelbrick and you will be configuring it”. Jump forward to August 10th and I am installing into Sandbox. The next 55 days were a blur (Oh yeah, we went live last Friday, 55 business days after starting!) …taking training, reviewing documentation, asking questions, redoing, redoing and redoing… The net result is, however, that on October 28th we went live with Salesforce CPQ.

Now that you know the setup, let’s get on with the rest of the blog. First off, some high level process orientated goodies.

  • Have someone who knows the company build out the smartsheet workbook…and it should not be the sys admin. I am SUPER fortunate in that my boss was able to crank out the smartsheet doc for me to start with. If I had to do this myself, it would have been a huge timesuck.
  • As a sys admin, figure on 100% participation on this one. I am estimating an easy 400+ hours to get this puppy up and running. Of course, if you read this blog post and follow some of my suggestions, you should be able to shave at least 10% off that total. But, long story short, make it widely known that this is your priority.
  • Simplify where you can. Do you really need that approval step? Do you really want a listing for Product X that makes you no money and you only sell once per year?
  • Embrace the Chaos – things will change. Stay flexible, learn the tool and prepare!

OK –  think those are some good pieces of advice to start with. Now, let’s get into some fun stuff. Here are my top pieces of actual technical advice.

  • If you are running with basic approvals, build out your approval steps as formulas that can be referenced by the approval process. This is perhaps one of my favorite all around tips for salesforce, but super applicable here. Let’s say that you have an approval process that looks at a specific percentage field and you only want an approval to happen if that field is above 50%. IF you have activated that approval process and then need to make a change, you will have to clone / activate / test etc… However, if you make the approval step a yes / no formula that looks at your fields, you can adjust the formula without having to monkey with your approval steps.

~ What? You want SFDC specific stuff? OK – fine!~

  • Create an admin layout for quotes / quote lines. Seriously, go in there RIGHT NOW and do it. Then, add all the SFDCcPQ fields to that layout. This will save you a bunch of time.
  • On the topic of new things. Go forth and create a CPQ ADMIN App. You will then need to create a bunch of new tabs for it. I created tabs for block prices, line columns, actions (products / price), dimensions (products / price) and template sections. Throw that stuff along with the OOTB tabs on the admin app..you will thank me later.screen-shot-2016-10-31-at-1-43-50-pm
  • Replace the “New Quote” button. So, just for a good exercise, after installing the package, create a quote with the out of the box new quote button. It is brutal. I replaced this with a “Create Quote” button that uses a flow to bring over all the fields I need and also to ask any questions. The net result is that I get less confusion and a way faster process.
  • I also want to call out the field “Watermark Shown” on the quote layout. This field is what controls if a watermark is shown or not. Add it to your layout and be aware that it defaults to unchecked, so will have to devise a mechanism to default it to checked (Cough, flow, cough).

I think this covers the basic stuff. I will try to write more as I think of it. Overall, the experience was a good one. I would HIGHLY recommend that if you are a small shop and you can spare your sys admin for a couple weeks that you try and do this yourself. It is totally doable and as an upside, you get to know where all the dark corners are and how to fix stuff on your own.

Anyone else mess with SDFC CPQ? What has been your experience? Any specific section of the above post you want me to expand on?

Fuzzy Searching in Salesforce Flows

Standard

Salesforce flows are a magical thing, like good coffee at work and unicorns.

coffee unicorn.jpg

This is how I want my coffee delivered.

 

I have come to realize that there are limits to even the most magical things (BOOO!).

The limitation I have found in flows is around how you search for records…but, let me be clear, it really isn’t a big deal. For most people, finding records using the typical “equals”, “contains”, “starts with” and “ends with” functions will work just fine. I however, found myself going down a path where that wasn’t going to quite cut it. The challenge is how to search on a text input in a manner that is more google like. I don’t know what the kids now a days call it, but back in my day, we might call if “Fuzzy Matching”.

Fozzie_bear.png

Fuzzy, Not Fozzie!

For example, let’s revisit my Jaeger Dispatching System (Special Note, Pacific Rim 2 is scheduled). This system uses dynamic drop downs for the Jaegers, but, what happens when you have a bunch of Jaegers’?  You can build out a record search based on a text box, but, as mentioned before, you are limited to “equals”, “contains”, “starts with” and “ends with” functions. At this point, you might be saying, fine, just use a “contains” operator…and that would work, except what happens when the user spells something wrong? Contains is just two wild cards, so if you entered in “Dangur” instead of “Danger” you would not get a hit.

 

What happened next is pretty funny. I started thinking about how there are patterns in words…and then started thinking about how the pairs of letters could work. Spoiler alert, it totally worked. I proved it in Excel by just using a vlookup and some formulas, so I got pretty excited. It was then that I googled this matching pairs thing and found out that yep, some one wrote about all the fancy math behind it.

http://www.catalysoft.com/articles/StrikeAMatch.html

So, after building out the proof in Excel that this would work, I set about trying to get this to work in Salesforce…specifically a flow. I want to be able to enter in some characters into a text box and see returned results based on how well they matched my search term.

The first thing I did is create a field that removes the spaces from the Jaegers’ names and made them lower case. I don’t want it being “Cherno Alpha”, I wanted “chernoalpha”. This is done via formula field. If doing this in real life, I would build out my formula to also remove punctuation, but this is just for my Jaeger dispatch and my blog, so I am just removing spaces.

Thus, concludes the non flow part of this blog…what follows next is like 100% awesome, you have been warned.

TAKETHISCAT.jpg

Woot! FINALLY got to use this meme!

The first couple things are pretty basic, I have a start screen that has a text box. Next, I have a fast lookup on my Jaeger object. This gets all the Jaegers and puts them all in a collection. Next up is my loop, where I go through each Jaeger record. The only “gotcha” is that when you do the fastlookup, you need to bring over your formatted text from the record. Screen shots of this would be pretty boring, so here is a picture of all the giant robot toys.Jaeger Toys.jpg

Within the loop, I start with two assignments that copy the formatted Jaeger Name (no spaces) and the search string to variables.
I am going to use these variables for the rest of the functions, including the formulas. I take the search string that was entered and format it up.  I remove the spaces, count how many pairs I have and if the value has a remainder, I also remove the last character. I do this because otherwise the matched pair logic would be searching on a single digit, which would skew the results. The formula also checks if the search string is just 3 char, and if it is, it will treat these three char as one “pair”. Pictures and Text!

Formatted Search String

if(len(substitute({!Search_String},” “,””))<>3,
if(
mod(len(substitute({!Search_String},” “,””)),2)<>0,
left(substitute({!Search_String},” “,””),len(substitute({!Search_String},” “,””))-1),
substitute({!Search_String},” “,””)),substitute({!Search_String},” “,””))

Now I have to compare my first matched pair to the formatted name. of the search string that was formatted. I use a formula to get my matched pair:assignment - formatted search string.png

if(len(substitute({!Search_String},” “,””))<>3,
lower(left({!varSearchStringUseCopy},2)),lower(left({!varSearchStringUseCopy},3)))

 

The flow will next do a name check via the decision function. If the Formatted Jaeger Name contains the current matched pair, the flow adds a value of 1 to the counter variable and adds the current pair to a variable that will show the matches and the ID of the current record to another variable. Ugh, that was hard to read, here is a picture:assignment - match found

If the pair is NOT a match, well, I don’t really do anything with it but you might want to shove it to a debug variable. In fact, if you are starting this from scratch, I would HIGHLY suggest you do this!

Next up is yet another assignment, this time though, we are removing the pair was just searched on. This is done with, you guessed it, a formula:

if(len(substitute({!Search_String},” “,””))<>3,
substitute({!varSearchStringUseCopy},left({!varSearchStringUseCopy},2),””),substitute({!varSearchStringUseCopy},left({!varSearchStringUseCopy},3),””))

remove search string

Once that is completed, we check to see if there are more pairs to check. This is done by looking at the number of pairs left after the current pair is removed. This is in a formula I like to call “DisappearingSearchString”:

len({!varSearchStringUseCopy})

The whole process looks like this:

match process

If all the pairs have been used, the flow then checks to see if there were any matches with a decision point on the counter variable. If yes, then we add the matching data into a variable and then start the loop all over again. Because we will want to display some results in a table like format, be sure to append a text template that has a line break at the end of the string. To do this, create a text template with <br> in it.

build out result line.png

One of the things I really wanted was a way to see how many of the pairs were found in a given record. I do this with this formula:

({!varTripCount}/{!frmSearchStringPairs})*100

 

Before the loop starts all over again, any used variables are reset:

clear counters.png

So, enough talk! Let’s see how this works! For comparison purposes, I put in an alternate lookup that will use the “Contains” search function of what was entered in the input.

I also added more Jaegers, 8 in total!

Jaeger List.png

boom

 

First search string is going to be “Eureka”:

Eureka.png

and here are the results:Search Results - Eureka.png

The “Contains” function did what I expected and returned two records, “Striker Eureka” and “Eureka Smack”. However, it did not find “Striker Eurek”, but the matched pairs function did!

Let’s try this on another scenario. Suppose there is someone new in the Jaeger Dispatching Center and they forgot that it is “Cherno Alpha” and they enter in “Alpha Cherno”.

Search String.png

The “contains” search function would literally return ZERO results, whereas the matched pairs function would show an 80% match with Cherno Alpha.Results - Cherno Alpha.png

So, there you have it. With a bit of work, you can do fozzie…err…fuzzy search results with in a flow with Zero coding!

As always, if you have any questions, comments, or suggestions, please let me know!

Andrew

One flow to rule them all.

Standard
One ring

Photo taken somewhere in SFDC HQ.

Recently, I found myself in a situation where I had a specific thing (Top Secret, Sorry!) I wanted my flow to do, but across multiple types of objects. As I built out my flow, I kept thinking, how can I build this so that it is a smarter flow? One that can accept multiple starting points? Well, to quote the announcer voice, “We have the technology, we the ability…”

But, let’s scooby doo intro back to the start…here is what I know:

  • The functionality I wanted to build involves doing a similar action against a lead, account and opportunity.
  • I can use a workflow to kick off this change
  • I can use a flow trigger to kick off the flow

Let’s start with the flow. What I actually did is not as important and the method, so a neat screen shot is not needed! The key piece here is that I have an input /output variable named “VarPassedRecordID”. Beyond that, really the ONLY other piece of the puzzle is a couple of decision points, one for each record. The decisions are all looking at the prefix of “VarPassedRecordID”. If the prefix of the ID matches the criteria, then the routing goes to the designated action

Update Account.

Decisions with Actions

As a side note, I have started using this methodology in my criteria’s when I look for query results instead of looking for nulls.

The next step is the workflow’s. In my case, there are three workflows and each workflow kicks off a flow trigger. If you do not have flow triggers, go get them enabled! Flow triggers are great for these small jobs, though you could do this with the process builder as well…The flow triggers are themselves unremarkable. The only thing they are doing is passing the record ID over to the flows…wow, reading this one over, this is really boring functionality. Seriously, this is like trying to make a pair of needle nose pliers or a shop light sound exciting! However, like needle nose pliers or a good shop light, this is a very good piece of functionality to know about. You can add new object types in very easily and with out creating more and more flows.

Recap? Sure, why not, this blog post is seriously shorter than half my papers I wrote in High School…Size 12 font! Double Space! Times New Roman! Business, Business Numbers! Is it working?

tumblr_nm4d2wZ7Go1r7r8d2o1_500

  1. The workflow runs if the criteria is met
  2. The workflow kicks off a flow trigger, which passes over the record ID to the flow
  3. The flow analyzes that data, and based on the prefix, directs the data down the right path

The only real “gotcha” to be aware of is that if you are using custom object, the record ID’s might have different prefixes based on your environments. You will especially find this true if you are migrating up the custom objects.

 

As always, let me know if there are any questions, comments or suggestions!

 

Andrew

 

Dynamic Screens using Visualforce and Flows

Standard

 

Oh boy, do I have something real nice for you all today!

Real nice.jpg

Something Real Nice!

Let’s say, you find myself in the world of action adventure blockbuster “Pacific Rim”. You are tracking Kaiju in an object called “Kaiju” and and tracking Jaegers with an object called “Jaeger”. From the detail page of Kaiju, I create a new detail button called “Dispatch Jaeger” that runs a flow by calling a Visualforce page. I know this is not typical, but stick with me! This flow associates the selected Jaeger to the Kaiju so then the whupping can commence!

Kaiju vs Jaeger

That works pretty well, but a user will always have to be on a Kaiju detail page to dispatch a Jaeger, so it might be good to put something on the home page that allows someone to either dispatch a Jaeger on an existing Kaiju OR create a new Kaiju and Dispatch a Jaeger all at once.

The first place I went is the google verse because I thought I would just create a small Visualforce page with an input box on do some sort of URL hack to get it to push a value to the already created Visualforce page that launches my flow. Turns out, there is really no such thing as “small” when it comes to this type of stuff. Most of the articles I read involved some sort of controller, so my overhead went pretty quickly from one Visualforce page to Visualforce page + controller + tester.

Back to the drawing board I went!

2015-12-09 15_45_16-pacific rim whiteboard - Google Search.png

I remembered some early work I did with flows where I used a decision element as my starting point, which would then direct a user to certain pages. I decided to explore the option of using this, and it worked!

Here is what I did! I modified my dispatch Jaeger flow so that the starting element is a decision.

Flow Overview

Starting Decision

This decision checks to see if KaijuId is being passed over from the Visualforce page, which it would be if you were launching it from Kaiju Detail. If this value does not start with the prefix for the Kaiju record (This works WAAAY better than checking for null or not null), it redirects to the newly created “quick dispatch” screen element.

I added my Visualforce page to my home screen and boom, my flow correctly presented me with the quick create screen!Home Page

However, I still needed the ability to create a dispatch from the detail screen, so let’s click the button and see what happens!

Dispatch from Record Yep, the flow determines that I am running a dispatch from a record detail and points me to the right screen!

To sum it up…I was able to with Zero Extra Code, modify my flow so that two different screens are presented to the user based on if they were dispatching a Jaeger from a specific Kaiju, or were having to dispatch a Jaeger from the home page via a quick create function.

Dispatch jaeger VF code
You might also be wondering why I am using a visualforce page? Well, if you want to run flows in a community, you have to wrap that flow in a visualforce page…That being said, you can totally do this same type of thing with a URL launched flow too…the functionality is really the same with the novelty part of this being that it works within Visualforce.

So, that wraps this post up! Thanks for checking it, comments / questions are always appreciated.
Also, quick note, I will be at the Salesforce World Tour in Seattle on the 17th. I would be more than happy to talk about flows or other Salesforce awesomeness, just look for this guy:

Salesforce in Seattle!

I am smiling because I support Salesforce

Attaching a copy of an email alert in Salesforce

Standard

How long has it been? A long freaking time!
Long timeBetween summer vacations, coaching soccer and cub scouts, there has not been much idle time for this boy to blog, which stinks because there has been so much fun stuff figured out!

But, here I am, eating a turkey sammich, listing to some EDM on Slacker Radio and trying to get a blog post cranked out for you all.

What I am going to blog about is an annoyance that has been going on for quite some time… the issue of workflow email alerts. In fact, this idea is over 5 years old!

See, when you build out an email alert and it fires…well…it just fires. You can do a work around that involves carbon copys to an email to salesforce box or creating activities, but those workarounds are either not scaleable or they don’t give you much more information than “this email was sent!”.

But, I did find a work around that is scalable using my favoritest thing ever, flows*. Now, did you see that little thing there? That Asterix? Yep, that is there for a reason. It is there because I wrote this out using flow triggers. I am sure you can do this with process builder, but I am just documenting the flow trigger function here. I like process builder, but in this case, I just need to crank something out quick, so I am using triggers.

The “Too Long; didn’t read” version is this. I created a flow that runs via the workflow (remember, I am using flow triggers!). When that flow trigger runs, it will do two things. It will send off the email alert AND create an emailmessage record. Yeppers, I said create an emailmessage. What I have found is that within salesforce you can create an email record through a flow and it will happily sit there. The trick is that you will need to pass the record ID from where you are starting and use that ID for the “parent ID” field on the emailmessage record.

This is a good jumping off point if you want to venture forth and tinker around yourself. For those of you that want more details, here ya go!

My assumptions at this point are that you are comfortable creating your own method of running this flow. As long as you can pass variables over from the record, you should be good to go. This flow only has two elements. The email alert (which is already built) and the record create for the email message. There are a bunch of things you can build out when you create the email message, but I am just going to cover the basics.

  • Parent ID – this should be the record you want this emailmessage living under. In my case, it was, well, case.
  • Status – Status is a funny one. It is displayed in plain English but the value is actually numeric. In my case, I am recording a copy of a sent email, so I used a status of 3, which is “sent”.
  • EmailMessageBody – An interesting thing about this method is how the text is displayed. You will actually be creating the emailmessage.body by using the field “HTMLbody” and to make it so the text looks nice, you will need to do the following:
  • Create a text template called “LineBreak”. This text template will just have the HTML value for break “<BR>”

Line break

  • Create a text template called “Email body”. Enter your data and insert the text template “linebreak” wherever there should be a line break. If you need to get values from the parent record, insert them here. I choose to pass them all over via the flow trigger, but you could just as easily do it with a requrery.

Linebreak being used

The end result is that the emailmessage you created via the flow will have a similar look / feel to the email that was sent out via the alert. Actually, it will look way more like the Text version, but really the point is to have this copy not so much to look pretty.

As I said before, I will leave the method of running this flow up to you, so let’s talk about the results.

By doing this, I was able to get a copy of the alert email attached to the parent. I was then able to remove the activity creation on the workflow since that was how we were noting that an email was sent out. The email copy is an actual copy, so we know what was sent out, which you couldn’t do through the activity. As an added benefit, running this via the flow allowed me to do some extra shenanigans that you really cannot do through a workflow, like running queries on other objects and adding them to the email.

The last benefit is crazy obvious, this is a LOW maintenance function. If a new value is added to the email alert, I (or another admin) just needs to add it to the record creation function…no dev time needed!

As always, let me know if there are questions / comments

 

andrew