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

 

 

Advertisements

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.

 

 

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!

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

The hot fudge for your visual flow sundae

Standard

Flows really are a ground breaking piece of technology.

were not worthy

It was evident last year at DF14 by how often there were talked about. More stuff is being added every release and there is a great big community of users!

UI based flows are awesome for internal user, just pop the URL into a button and instant awesome! A question that is constantly being asked is, how do I get the pop up window to go away”

See, when you launch the UI version of the flow, it does it’s merry little thing and then takes you back to the start, which is not always ideal! Being that we are all really clever folks in this community, there are a bunch of ways around this, but a lot of them require visualforce / apex or a URL hack…but not many of them actually address the needs I had:

  • I need this to run with in a community
  • I would like the window to close once the flow is completed

First things first, we need the flow to run in a community. According to page 115 of the Visual Workflow Guide:

“Enable external users to run your flow by adding the flow to a Visualforce page and distributing that page through a Force.com site, Customer Portal, or Partner Portal.”

OK, no big deal there. This topic has been covered extensively on this blog and others! As a side note, this is how you get flows playing nicely with Salesforce1, so head over here to learn more…I will wait!

Ah, you are back! Now that we have a flow that will run on communities or internally. How the heck do we get the flow to close out the window? Well, after googling various iterations of “closing visualforce window” I finally just decided to google something like “close browser window javascript” (This was after googling “Moscow Mule Recipes”).

I wish this just came from one source, but I was really using the google hive mind that day! What I ended up doing is using some javascript in a visualforce page called “ForceClose”:

<apex:page showChat=”false” showHeader=”false” sidebar=”false” applyBodyTag=”false” applyHtmlTag=”false”>
<html>
<head>
<title>ESCAPE</title>
<script>
function closeWindow() {
window.open(”,’_parent’,”);
window.close();
}
</script>
</head>
<body onload=”closeWindow()”>

</body>
</html>
</apex:page>

NOTE! If this code looks familiar to someone, please let me know so I can give you a hat tip from little corner of the web!
NOTE + 1! I still have my #ClicksNotCode card, so I would imagine this is not near good code!

Now I have a flow that runs in a Visualforce page AND a Visualforce page that should (in theory) close itself. It is time to…wait, I wish this step could be more dramatic…maybe you could read this in a monster truck voice? Just in your head so you are not disturbing your neighbor! OK, carry on…join the two pages together! Just set your finish location on your flow visualforce page to be the forceclose page!Add Finish Location

And, that is that! So, how does it work? Well, pretty darn good! The super sweet thing though is that this is reusable! I now used the “ForceClose” page 5 or 6 times in various flows, and that is really nice!

As always, thanks for reading the SFDCinSEA blog! If you have any questions or comments, let me know!

What (approximately) 48 hours with Apex has taught me

Standard

Friday afternoon, around 2:00 I got a message telling me to check out SFDC99.com. At first, I was skeptical, here is yet another blog that is going to teach me Apex / java/ html etc…I had read it all before and have failed just about every time. Part of it was how the knowledge was presented, part of it was me saying “It is 20XX, why am I still having to write lines of code” and part of it was that I can do a BUNCH of cool stuff already with the goodies in Salesforce, what will learning Apex do for me.

Apparently, not my future.

Where we are going, we don’t need code

This blog was different though, the tutorials were written in a conversational and logical manner that made sense and also didn’t come across as a developer talking to a kindergarten class.It also dawned on me…I was doing this stuff already. Sure, it might be through flows or crazy clever formulas and workflows, but the logic was there. My bias was pretty much erased completely once I saw this question:

1. If you can solve a business need using either a workflow or a trigger, which should you use?

Always use a point-and-click solution (workflow) when possible!

  • It’s easier for your team to create and maintain workflows
  • Workflows are easier to find when debugging unexpected behavior in your org
  • Workflows never break!
  • You don’t have to write test classes
Pretty much every developer I have ever worked with

In internet time, this meme is so old it farts dust

The reason this question really hit me was because I have ran into MANY developers that are code first, ask questions (and write documentation, test, get feedback on, deploy correctly) later.

Having seen and supported the aftermath of this type of developement, I really took a to the whole #ClicksNotCode and #ButtonClickAdmin philosophy to heart. Seeing a developer actually answer this question like I would was like a golden ticket.

Golden Ticket of Apex

First time your class runs with 100% coverage (even though trigger is 5 lines)

It told me I could still believe in all the good stuff that makes a system like Salesforce.com great WHILE learning the dark side.

So, it has been approximately 48 hours since I started doing this thing, and here is what I have learned:

1)      Just because you know code doesn’t mean you know salesforce.

2)      APEX is way more intuitive than whatever code you might have tried to stumble through last time.

3)      I am really thankful for my time supporting traditional CRM systems (Cough, Siebel, Cough) and having to muddle through gnarly SQL statements.

4)      Having to have 75% code coverage is tough, but if you think about what you are trying to do with your trigger and then build out from there, you will do good.

5)      Try and think how you would write a trigger to handle every transactions like getting coffee.

Next steps? Well, I just got my Head First Java book and have been working through that. Honestly, so far installing the JAVA SDK seems to be the hardest part (and I have installed Linux!), but that really isn’t a surprise since it is an Oracle Product.

Clicks not Code Larry, Clicks not Code

The new westcoast beef

I am also going to keep plugging away on the SFDC99.com tutorials. I have went through Chapter4 and am going to spend some time here getting a better grip on the basics before I move along. I am also going to keep “doing what I do” in terms of new functionality in SFDC. I love all the fun stuff like flows and workflows, but much like a padawan with a new lightsaber, I am going to try and use it as much as I can.

Nuts! My lightsaber test class only ran 45% of the lines!

I missed class picture day

 

Andrew