I Wanna Flow Clone!

tumblr_mva7uoLfIh1sn7lxto1_1280

Brian and I talked about this on this week’s WizardNews WizardCast, but we thought perhaps a text-based walkthrough might be in order. So let’s talk about clones, baby.

The clone button on Salesforce records is great, for obvious reasons. But it has one major shortcoming: it brings over EVERYTHING.

Let’s say you want to clone a case, because a second client is having the exact same problem 3 months later. For one, it’s probably not going onto the same account, or have the same contact. For another, the Case Status probably needs to be reset to its earliest setting, since the original Case is (hopefully) closed.

But keep in mind that a mature Case object may have many fields that are NOT on the page layout, but nonetheless important to maintain. You may have an Approval Status that keeps track of approval steps but is hidden to prevent modification. You may have date fields that log when certain events occurred, but again, are hidden for security. You may have checkboxes or other fields verified by validation rules to ensure changes go through proper channels, like API or Flow.

These are all data points that you would NOT want to be brought over in a clone, because they are probably not going to be accurate for your new Flow.

So how to clone while still ensuring that existing data doesn’t become bad data? Simple! Flow!

Flows can be fired off of buttons, just like cloning, so that makes it an excellent candidate, plus Flow has the ability to read existing records and create new ones. Let’s take a quick look at what needs to be done.

We’re going to assume, to start with, that we’re going to be passing in the ID of the case we are cloning. We only need to pass that one piece of data in, because we can get the rest later. Let’s make a new variable: varCaseID. Don’t forget to make its Input/Output Type “Input Only”, so it can receive that data. If you leave it as Private, it’ll never be able to receive data passed to it.

Screen Shot 2015-04-08 at 14.10.32

Now that the Flow has a place to store which Case we are cloning, let’s get the rest of our fields. Create a Record Lookup, and set the filter to look on the Case object for a record where the Id is equal to our new variable, varCaseID. This is all you need to define, because you’ll only ever get one record with that ID!

Screen Shot 2015-04-08 at 14.13.34

In the section below, you will need to manually define which fields should get brought over in the clone. Yes, this may get tedious if you have a lot of fields that need to come over. But I would highly advise confirming with your stakeholders which data is truly needed. You’ll find most of your fellow employees or executives only want the data they really need, and are happy to let the rest go. You will need to store each of these data points in its own variable, and those variables can remain set as Private, because the Lookup will go and get the data; it’s not the same as having data pushed to it.

Screen Shot 2015-04-08 at 14.23.32

For the sake of this example, let’s assume the Account and Contact are the same; this is a whole other can of worms that would practically take a whole other article to examine properly.

Now that you have your old data brought over, we can begin creating our clone. All we need to do is add a Record Create to the Flow, and set it to create a new Case. Then, in the fields below, you can assign all of your variables to the proper case fields, like so:

Screen Shot 2015-04-08 at 14.29.12

That’s it! Draw an arrow between from the Lookup to the Create, and click the Start icon (the green arrow circle in the top right) on your Record Lookup so the Flow knows where to begin. You can now save your Flow, and create your Clone button.

Screen Shot 2015-04-08 at 14.38.16

Once you’ve saved your Flow, close it to get to the Flow’s information screen. On this screen, you’ll see a URL; copy this to your clipboard, you’ll need it in a second.

Screen Shot 2015-04-08 at 14.38.30

Now on to the button itself. I prefer calling the button something else, to reduce confusion. Something like SmartClone, to let you and the users know that this button is smarter than the average Clone. Before actually defining the button itself, I suggest changing the Behavior to “Display in Existing Window without Sidebar or Header”. This will effectively replace the contents of the users’ open tab when they click the button.

Now the URL for the button. Paste the URL you saved from your Flow, and add the following:

?varCaseID={!Case.Id}&retURL=/{!Case.Id}

Screen Shot 2015-04-08 at 14.44.05

Here’s the breakdown.

  • The ? is important because it lets Salesforce know to expect settings to be set in the URL. Each element we pass is essentially something we are setting this URL to do.
  • varCaseID – This is the variable we created, remember? Putting this here tells Salesforce we need to send something to this variable when the flow is started.
  • {!Case.Id} – This is a merge field that turns into the Case ID itself. You can generate this via the merge field operators right above the URL window, as always.
  • & – We can pass more than one piece of information, but we need to separate each one with a & symbol.
  • retURL – Here you can set where the Flow should go when it is done. If you do not set this, the Flow will just repeat over and over. By passing it / then the Case ID again, it knows to go back to the Case that started this.

It may help to put your varCaseID and your retURL on separate lines in the URL window. Adding line breaks won’t cause any problems, as they get ignored, and it makes your URL a lot more readable when you have to support/troubleshoot it later.

Voila! Put this on your case page layout, and you’ve got a SmartClone!

Advertisements

The First Not-Really-Annual-We-Just-Do-This-When-We-Feel-Like-It Community Flow Hackathon!

2012.05.04-HackathonOn the 25th of June in the year of our lord 2014, it was hereby decreed that there would be a great ‘Thon of Hacking, dedicated to the communication of ideas and knowledge of The Great Flow. Over the following 7 days, many heroes from across the land ventured forth to slay the Dragon of Communal Ignorance, valiantly submitting their contributions and felling the great beast. When the dust cleared on the 2nd of July, there were only victors.

Hang on, I think my nerd is showing. Can you tell I run Dungeons & Dragons games in my spare time?

If you have any interest in Flow, I highly advise heading to the Success Community page for the #Sp14FlowHackathon topic, where you can see the collective hackathon in its entirety. It was started in the group “Official: Salesforce Workflow Automation“, and there truly were some amazing ideas. I’ll be dedicating an entire blog post to my submission next week, but at the moment I want to highlight some of the other submissions here.

(The following “awards” are mine and mine alone, and I do not represent Salesforce or any other company or individual.)

Best Use of New Features Award – Reassign Records when the Owner becomes Inactive

Jen Nelson brings the awesome with a Flow that uses Flow Triggers, Fast Lookups and Loops seamlessly. What’s more, it’s incredibly useful to ANY admin and operates quietly, predictably, and seamlessly. It’s the sort of automation that throws off new admins in the org; it’s so clean that it fools them into thinking it’s part of core Salesforce functionality, not realizing something else enabled it. Hey Jen, be sure you train any new admin you work with that this is flow! Otherwise he’s going to get that question wrong on his 201 Certification test!

Most Work Saved Award – Assign and Maintain Due Dates for all Tasks in a Campaign

Jen Dunn not only wins the award for Most Work Saved, but also for Most Patient Users! Whoever had the job of manually assigning and updating up to 35 tasks had a crap job, and Jen made it a whole lot easier! I just hope you didn’t put someone out of a job! This is a prime example of the power of Flow: taking a massive, repetitive task and reducing it to a few clicks. Bravo.

Wildest Idea Award – Clone Chatter Group with Members

Rakesh “The Flow Machine” Gupta makes us all ask ourselves the deep philosophical question: “Will I ever have to clone a Chatter Group? And if so, what am I going to do about all those Members?” That’s heavy, man. So hardcore. If nothing else, I love Flows like this because they make admins stop and say “Wait, Flow can do THAT? If it can do that, I wonder what else it’s capable of.” Nothing better illustrates the breadth of awesome that Flow can accomplish.

These are just some of the Flows that were shown. Go and take a look at the rest!

 

Getting Record Type IDs in Flow without Hardcoding (UPDATED!)


check-yourself-before-you-wreck-yourself

Have you ever migrated your Salesforce data or fields into another org? Do you develop your new features in a Sandbox first? (And if not, WHY?)

If you answered “no” to both of these questions, ask yourself if you can safely say you will NEVER do so.

Chances are that any given admin will, at some point in their admin career, have to either migrate at least some part of your Salesforce, or at the very least be REQUIRED to build something complex in the Sandbox first, so as not to impact current process. If your company gets acquired, there’s a very good chance you’ll have to merge orgs.  One way or another, you’re probably going to be beholden to this fact of life. The business world necessitates preparedness for just such an eventuality.

Previously, I had thought this would never be a problem. I’d never had to release anything that was so impactful that I couldn’t build in production and delay its effect (pardon me a moment while I slap my own wrists). I didn’t anticipate a full org merge with another Salesforce org, though I really should have. So I didn’t foresee the pain that would be, the horror known as: HARD-CODED RECORD TYPE IDs.

hardcode

THEHORRROR

You may think that using hard-coded IDs is not a big deal, and if you only have one or two uses, it’s probably not. But over time, the practice can become pervasive in your admin methodology, and it will then grow well beyond those happy few. I mean, let’s face it, most of the time it’s a lot easier to deploy than other solutions, right? Just referencing a single ID is a lot simpler than writing the formulas, workarounds and methods needed to not use them, right?

The trick is, this trap has two kinds of cheese. The first is the fact that it’s usually easier, but the second is the fact that we as admins and developers often come to the conclusion that there is no workaround. Years ago this used to be the case, but today we have a lot more tools at our disposal, and many of the cases where we would be forced to use a hard-coded ID are not actually cases where we are truly forced, if we just keep working and digging at a solution.

Then I had an org merge to work. Because of our long-standing practices in our 5-year-old org, we had hundreds of single hard-coded IDs in our system. The trap had closed. In order to merge our system into theirs, we would have to reconcile ALL of those. We had a mountain of work ahead of us, because we had not looked ahead.

In working on solutions, I have developed a way to avoid hard-coded Record Type IDs in Visual Workflow. This has traditionally been a place which is widely considered to be inescapable for hard-coded IDs, but today I say thee NAY. There is a way!

(UPDATE: I had previously published a kludgey way of doing this, but it turns out there is a better way to do it that Salesforce has provided! Special thank you to MVP Aiden Martin for pointing out this exists!)

Screen Shot 2014-06-17 at 12.50.33

Create a Record Lookup, and when choosing what object you’re looking at, choose “RecordType“. Many an admin have glossed over that picklist choice, not even realizing it’s there, but this is an object usually referenced by Apex or API for the purposes of finding RecordType information. Because it’s in the API, we can use it in the Flow!

In your filters, choose “SobjectType” and set this to the object whose record type you are looking up. To determine which record type to use, I recommend using DeveloperName instead of just Name; the Name is the equivalent to the Record Type’s label, and is more likely to change. By basing it on the DeveloperName, you’re less likely to have issues with the name changing and breaking your flow.

Assign the Id value into a variable for use later and BOOM! You now have your Record Type ID stored in a variable for using later in your flow, and you didn’t have to manually enter it into the Flow. If the Record Type changes to a different ID in the future (and odds are it will), you will not be screwed. I REPEAT: you will NOT be screwed.

How I Learned to Stop Worrying and Test My Flow

darthvadertestingDo you write Flows? If so, congratulations, you’re a developer. No no, you are. You’re developing software, just with a declarative interface, so yes, you’re a developer. And what does every developer have to do, even though they hate it?

Test. Test. Test.

Once you’re a developer, you’re not exempt any more! Welcome to the development world. Yes, we hate testing. We like to think our Flow is just going to work the first time, but in all of the 30+ flows I have written in my time, I can only say that I am just lucky enough to have gotten away with it once. Seriously, that’s like a 3% chance.

Even then, I played it safe, and verified that it was going to work right by testing it first. You will save yourself SO much time and frustration by testing before deploying.

Flow is a unique beast, though, and there’s not a lot of documentation out there on how to test your stuff. By and large, we’re left wondering just what we should do to actually test. There’s some obvious things, but then the only truly obvious route is to actually deploy in order to test, and that’s not always a good option.

So without any further ado, here are some of the methods and guidelines I have come up with for testing my Flows.

1. Sandbox Sandbox Sandbox

sandboxes

I know sandboxes seem like a waste. I know the concept is alien to some of us. But really, do it. DO IT. This is especially important for Flow Triggers, which, I can attest to personally, can cause stupendous failures.

When a Visual Flow crashes, it only affects the person trying to run the flow, and usually just throws an error. When a Flow Trigger crashes, that crash can affect ANYONE who is trying to do their work. Even if you have “Administrators run the latest flow version” turned on, you can still have problems if you haven’t activated any versions. So trust me when I say, Sandboxes are more important than ever before for Flow.

2. Always Fault

There’s nothing that your users hate more than a cryptic error. Seeing

An unhandled fault has occurred in this flow. An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

is the surest way to frustrate and confuse, not to mention driving your users AWAY from using your blood-sweat-and-tears Flow. Nobody wants to use a tool they don’t understand, so quite simply, they won’t.

So how do we avoid this? We add Faults.

Screen Shot 2014-05-06 at 13.54.13

Every Create, Update, Lookup, or Delete.

Any Record or Fast Element can have a Fault element attached to it, and your best practice is to ensure that every Record or Fast Element has a Fault element attached to it. A Fault element can be made by creating any element and drawing an arrow to it from your Record or Fast Element AFTER they already have an arrow pointing to another element. If the Flow errors on that source element, it will then perform whatever is in your Fault, rather than showing that “unhandled fault”. That’s what unhandled means; it means that you haven’t defined what should happen when a fault happens.

A fault can contain a message to the user, it can create records, it can even send an email if you use the Email Plugin. Anything Flow can do, you can make happen from a Fault, so this is invaluable not only to your users, but also to your debugging and testing. Having a screen that tells you what your variables’ values are AT the point of failure is essential.

Another quick tip: if you want your fault to do things AND present a screen (I almost always have mine send an email and then show a customized error in a screen), do the email or other things first, THEN do your screen. If a user gets an error message screen, they are a lot more likely to exit the screen instead of clicking the Next or Finish button, and if they don’t click that button, it WON’T fire your email or other actions.

3. Gotta Test ‘Em All

portalmon-shirt

This is another drudgery chore, but as admins I cannot stress enough that you have to personally try out your functionality. Don’t just try your flow while logged in as you; try it while logged in as the actual users who will use it. Try each choice option you present in your screens, or at least a sample of them, if there are too many to test. Make sure you run your Flow through every possible decision path, to be sure each decision path actually works.

Also, try your flow while logged in as the actual users who will use it. What, I already said that? Well, good, it needs to be said again. It’s so easy to forget to do, because you have to do it in a sandbox in order to do it safely, but it’s one of the most important things you can possibly do in your testing.

So How Do I Test Exactly?

The Temporary Assign Element Method

Screen Shot 2014-05-06 at 13.58.00

The Run button is a great option in the Flow Designer, but unfortunately it’s fairly useless without some setup. Almost every flow needs some data passed to it, and that Run button cannot pass any of that data. So how do we make it useful again?

Create an Assign element BEFORE the start of your Flow, and in it, assign some sample data to the variables that would usually have been set. Draw its arrow going to the start of your Flow, and then make the Assign element the actual starting element.

You can now use the Run button with impunity! This makes testing a lot faster when you don’t have to click around to get to your Flow, and it has the additional bonus of being able to test your Flow (at least, the testing that you do while logged in as you) without making it live for everyone. It’s a great way to do quick proof-of-concept testing as well.

Please keep in mind this doesn’t work on any flow with sObject variables or collections at this time.

The Screen Debug Method

Screen Shot 2014-05-06 at 14.06.44

This ties in directly with bullet point 2 above. If, in your testing, you hit an error or bug or other unexpected result, being able to insert a temporary Screen that just repeats what the variables or Screen Choice values are at any given point can be the key to unlocking the mystery behind your dysfunctional flow. There is no reason this cannot be done at any time; you can insert this into the middle of your flow’s track without having to use a FAULT path, so you’re seeing things as they happen, even before the error comes down.

Of course, because this method uses Screens, it is incompatible with Flow Trigger flows. Bummer.

[Edit: Removed the Flow Debug object method. Turns out this has some pretty glaring issues with most faulting in Salesforce. Thus reiterates my overall point about being extremely thorough in your testing of, well, anything.]

New Tech for Flow Triggers: Complex Validation Rules

Street_Fighter_III love Salesforce, but in my spare time I do a lot with gaming. I have a particular interest in the fighting game community (or FGC as it is referred to by its members). The FGC subculture is very competitive, but also very tight-knit, and this closeness, combined with time and creativity, has formed its own subcultural lingo, with terms like “salty” and “happy birthday”.

One of those terms is “tech”, which is short for “technology” but is often used more like the word “technique”. When someone comes up with “new tech”, it means they have devised a new trick, and if it’s useful, it’s likely to be seen and repeated by other players. Because of the social nature of the FGC, with tournaments being streamed live and higher internet speeds now making online matches a viable place for competition, new “tech” can often spread around the world and be used professionally within a matter of days.

Granted, not all new tech is actually useful.

Granted, not all new tech is actually useful.

In a lot of ways, the Salesforce community is similar. Admins and developers create “new tech” all the time, and with all of the online tools like the Answers community, the official Collaboration groups, and the blogosphere, the tech gets spread quickly from admin to admin, developer to developer. Just look at SteveMo’s posts; the amount of new tech he comes up with for reporting is insane! (The “Power of One” piece of tech is practically iconic!)

So last night I had a flash of inspiration for some new Visual Workflow tech, gave it a try, and met with some moderate success. It is dependent on Flow Triggers, so if you don’t have that pilot yet, this won’t apply to you, but that’s ok, because this tech isn’t quiiiiite usable yet by anyone. But we’ll get to that.

Here’s the concept: Let’s say you want to ensure that an opportunity cannot be Closed Won if it contains Product A BUT does NOT contain Product X. Previously, this was not possible without Apex, because validation rules do not run in that direction; you can control your Opportunity Products based on the Opp, but you cannot control your Opp based on the Opp Products. This is now possible, however, with flow triggers.

743fabfe0b248e2b2d1a7ca02f3729cdc8b69bd59c0912f4dafbb6e3944eae5c

To start with, you’ll need to make a new checkbox field on your Opportunity. For this example, let’s call it Product Validation Alarm. Don’t put it on any page layout; you won’t need to actually access it. It just needs to be there, and it needs to be writeable by every profile. Once you have this, make a simple Opportunity validation rule that checks if Product Validation Alarm is TRUE. That’s it, nothing else needed!

Now that we have that to start with, let’s make our flow!

As a proof of concept, all that is needed here is a flow that sets that Product Validation Alarm checkbox to TRUE. If we were doing this for real, we would set up a Loop element with a Fast Lookup to parse through the OpportunityLineItems looking for any that match Product A, but for just the proof of concept, this is all we need.

Screen Shot 2014-04-28 at 13.43.55

 

A simple flow trigger can then be set up with any workflow rule. I created a rule that just looks for Stage to be changed to Closed Lost. In our scenario, you could have this go off when the Stage is changed to Closed Won, if you just want to set up the proverbial bouncer at the door of the club, or even when the Opportunity Product is created, if you REALLY wanted to be prohibitive.

Note that in the Flow Trigger we will have to pass in the opportunity’s ID to our Flow’s variable. (I LOVE that we can do this here instead of having to define arguments in the URL!)

Screen Shot 2014-04-28 at 13.50.38

 

Basically, what we are doing here is PURPOSEFULLY setting up criteria that will trigger a validation error. But we are using Flow to be the watchman that presses the Alarm button, rather than relying on a validation rule that cannot even fathom what might be happening. It’s like hiring a physicist to watch the Large Hadron Collider for anything that might go wrong, as opposed to hiring a 7th grade science teacher. (No offense to 6th grade science teachers, mine was completely awesome, super smart and one of my favorite teachers ever, but she probably wouldn’t have been able to be an overseer at CERN.)

Now, here’s the catch:

rtaImageThis is why I was saying that no one can really use this right now.

Right now, when Flow causes a Validation Rule error to fire, this is what it displays. It doesn’t actually show the validation rule’s error, and it doesn’t appear to be an option at all to display it.

This IS currently effective, however, at stopping users, even if it does not tell them why they are being stopped. It’s not good UX. If you’ve got reeeeaally savvy users, you can use this and give them a list of the flow IDs as they correspond to what is being blocked. Or, if you have only one of these errors, it’s relatively easy to train your users that when they see this message, it means they did {insert problem here} wrong. But even then… new hires come on, people forget because they don’t hit the error for months… it’s a minefield of possible problems.

So if you want to see Flow Triggers being able to be used as complex validation rules…

Go-Vote-500x500

There is an idea on the Salesforce Success site requesting this very thing. Give it a thumbs-up to make sure this happens!

In the meantime, this still serves to show the sheer power of Flow and Flow Triggers. Go forth and use that power!

keep-calm-and-have-the-power-5

Video

Visual Workflow Live! Complete Task and Notify

After wrestling with YouTube, I FINALLY have this video up and ready. Needless to say, I have learned a few important things from my first live-streaming experience:

  1. Do not play background music. Chances are it’s copyrighted, and YouTube will either restrict it or block it. Sorry, Salesforcers in Deutschland, this video won’t work for you. 😦 It also means the last few minutes of audio got muted forceably by YouTube,  so I had to annotate it manually.
  2. Do not check your own stream on the same computer you’re recording on. It’ll pick up and audio and you’ll have two audio streams being recorded simultaneously. It’s kind of like a time machine, thanks to the 20 second delay, but not as cool.
  3. YouTube’s built-in video editor is OK. It works for what I need. Might need something more advanced someday, but for now, it’s good.
  4. Need more people in the chat! Had at least one person in the chat contributing, and it was a big help. Thanks lifewithryan!

So without further ado, here’s the video from last week, and look forward to more video coming soon!

Post to Chatter from Visual Workflow

tennyson

One of the most marvelous aspects of Visual Workflow is the fact that you can hit any API-based object from it. If it’s listed here, you can generally read, create or delete from it (with a few exceptions on protected objects, of course). It’s a surprising amount of power, once you dive into it. Today we’ll look at one of those possibilities: making Chatter posts from Flow. If you’re hip on upcoming events, you’ll know that the Salesforce product team is working on adding a new regular workflow action to post to Chatter (SAFE HARBOR!), but until that day comes, welcome to your one-and-only method of Chatter automation.

Well, you could always code something in Apex. And I suppose you could find something on AppExchange. Ok, it’s not your ONLY solution but it’s a pretty damn good one.

The key to creating a Chatter post is using the object “FeedItem”. “FeedPost” sounds more applicable, but it’s actually counter-intuitive; FeedItem is a newer object that replaced FeedPost (I believe this was done to enable other types of posts, like polls and dashboard components).

You can use the Create Record element, and only a few fields are required for your post.

feeditem

The field “Body” is absolutely necessary. I highly recommend making a Text Template in your Flow and calling it for your Body. If your post is super-short, though, you can just type in what you like.

ParentId is also necessary; this is the Salesforce ID of the record that this Chatter post should be on. You can make it a User ID to post it on their wall, but best practice is to place it on any object that has Chatter Feed turned on. (You may also see a field called RelatedRecordId; this is actually a field only used when attaching Content to a Chatter post!)

LinkUrl and Title are optional; they are used if you wish to post link in your Chatter post. You can type in both of these fields manually, and you can even merge in Flow variables by manually typing in {!variableName}, as shown above.

There are other fields, and some of them may seem necessary, like Type. However, these fields are set to contain default values, and almost always, those default values are what you will want to use, so really the above fields are all you need to worry about.

Other Considerations

  • At this time it is not possible to do @ mentions in your posts. Sad face.
  • Historically, you can use topics, albeit with limitations. If you put a # sign in your post body, the word immediately following it will be marked as a topic. However, it’ll just use one word, so you can’t do topics with spaces in them. I have not tested this in a Spring 14 setup, though, so I am unsure how this will work with the new Topics system.
  • BEWARE THE SPAM. If the Flow that makes a Chatter post is used frequently throughout the day, this will make a LOT of Chatter posts. This can be a good thing, but it can also be an extremely bad thing. If one use uses the Flow 10 times a day, those 10 posts are going to show up in the digests of every user that is following the user. If the follower is also following someone else who is doing the same thing, they now have 20 posts in their digests. If there was only 1 or 2 posts that actually contain something the user needs to see, and they get mixed in with the 10-20 other posts that, frankly, become very samey and ‘boy-who-cried-wolf’ after weeks or months of repetition, the Chatter digests will come to be ignored. I HAVE SEEN THIS FIRSTHAND. Nothing will kill Chatter usage and adoption like Chatter spam.

There you have it! Chatter post automation from Flows! Easy peasy! Now, because there has not been nearly enough levity in this blog post… narwhals.

Video

The Dreamforce 2013 Presentation with the Very Generic Name

Some of the sessions from Dreamforce 2013 have gone up on Youtube, and today my session went up!

Dan Harrison, Salesforce Senior Engineer, and I go over some advanced use cases for Visual Workflow. We’re looking into putting together a package with the flows that were demo’d, so hopefully that will go up soon.

Look for my post-Dreamforce post coming soon!

Flow Tools – The Best Plug-ins To Date, by Rajaram

A while back, the product manager for Flow, Varadarajan Rajaram, published on GitHub a series of Flow-based plug-ins and tools to make life easier using Flow. Truly, they were some of the best plug-ins ever made to facilitate Flow in Salesforce. Why they never made it into Salesforce’s core Flow offering, I’ll never know.

Now, however, Rajaram is no longer with Salesforce, and the GitHub page has been taken down. Thankfully, I did manage to download some of the source code, so I am making it available to the public here. It’s in the form of Apex classes and plug-ins, so you’ll likely have to use something like Eclipse and the good ol’ fashioned copy-paste to get them into your system. ANT can also be used, if you know those ropes.

I repeat: All of the following content is Varadarajan Rajaram’s, and not mine. I did not write any of this; I am just making it available in his stead.

And as always, install into your sandbox first!

FlowPicklistSync – Allows you to use existing Picklist definitions without re-creating them as Choices in Flow.

FlowShowAsYouGo – Shows how to create a dynamic Visualforce page that can get information from the flow as the flow progresses.

FlowPluginPack – Contains some of the plugins found in the AppExchange pack, plus a couple others: Submit for Approval, and Zip Code Verification.

Know Your Flow: Post-Its for Beginners

So here’s the thing. I WAS going to write a short series of blog posts on How to Get Started on Visual Workflow. It was to be a Great Work, a definitive treatise bringing clarity, insight and edification to the lay user, its sole purpose being to exist in this world as an utter personification of knowledge.

Then I saw Keith Sadler had beaten me to it.

Check out his awesome Part 1 and Part 2 blog posts over at ButtonClickAdmin.com to learn how to use Flow and get started on your very own real-world very-useful sample Flow. I’ve had some conversations with Keith, and I know first-hand that he really knows his stuff.

I LOVE Post-It Notes. I don’t use them as much as I should, due to an overwhelming and logic-disregarding need to use as little paper as possible. I mean, come on, this is the future, right? The only thing we’re missing is flying cars. Paper is soooo 2nd Century BC. Even Evernote is trying to digitize them.

Post-It Notes serve many functions, but one of the most useful ones is to serve as not just task reminders, but as impromptu cubicle posters: tiny pastel-colored mantras that remind us not just to pick up the milk, but to think or act in certain ways. An inspirational poster with your favorite motivational quote will often cost upwards of $5-10, but writing it in pen on a Post-It and sticking it on the edge of your monitor costs pennies at most, with the added bonus of taking up less space!

img_7011

Many such mantras are important for Salesforce Admins, or even for working people in general. I’m sure each of us knows at least one co-worker who would have benefited from having Wheaton’s Law permanently affixed to a prominent location in their workspace. And then there are the timeless admin Rules of Being Awesome put forth by Mike Gerholdt and the other MVPs; edicts like “Always build in the sandbox first”, or “Create trust in your data”, or “Communicate all changes!” These are, and shall ever be, key to success as an admin.

As such, I have come to call mantras like these “Post-Its”. They are friendly reminders on how best to work, and when it comes to Flow, there are certain “Post-Its” that one must remember as they begin their Flow journey. These are things that are not necessarily apparent, but crucial to keep in mind as you build your first Flows.

1. It’s Like a Flowchart, But It Does Stuff

Ok, you'll probably have more branching than this. Doesn't make it any less true.

Ok, you’ll probably have more branching than this. Doesn’t make it any less true.

If you ever have trouble wrapping your head around how exactly to build your Flow, the thing to remember is that it is, at its heart, a flowchart. If you’ve ever used Visio, OmniGraffle, Diagramly, or any of the myriad of programs that allow you to drop in shapes, write text, and draw arrows, you’ve done half of the work in Visual Workflow. The difference is, each of those Visio boxes can now be set up to DO something. ANYTHING. It’s extremely powerful!

Conversely, Flow works just like those charts do. It will only do things in the order in which you set them, and it will do things EXACTLY as you tell it to. Quite honestly, it is usually a great help to FIRST write out the flow you are thinking of, on paper or even in Visio, just to wrap your head around the logic, branching, assignments, and general order of things.

2. Screens Not Necessary (Mostly)

Almost every example or sample flow that you’ll see will have a Screen in it. And for the most part, great. Awesome. Communication is good. Generally speaking, you want to talk to your users as much as possible.

But what if you really don’t need to tell the user anything?

Notice there are no Screen objects here, except for the Fault error screen. We're doing a lot here, but it's all automation. There's no need to tell the user "Job done" and make them click another Finish button when they already know what's going to happen.

Notice there are no Screen objects here, except for the Fault error screen. We’re doing a lot here, but it’s all automation. There’s no need to tell the user “Job done” and make them click another Finish button when they already know what’s going to happen.

The thing to remember is that Visual Workflow has Workflow as its base. It can do nearly everything Workflow can, except that it has to fire off of a link or button. But in that sense, it can be treated like workflow.

Workflow doesn’t tell you when it’s completed successfully, does it? It just works. The same can apply to Visual Workflow as well. If you’re completing some simple automation with your link or button and you don’t need to obtain any additional information along the way,

Now I say this, but remember, my young Padawan, that only a Force.com Sith deals in absolutes. There are exceptions to every rule. Even if you don’t need to get any information or show a Finish screen, ALWAYS put in at least one Screen as an Error message/Fault. Generally speaking, each Record Create or Record Update should go to a Fault of some kind, even if they just share one.

3. Affect as Much as You Can

Some say that Admins have a God complex. And my response to that is, of course we do. Why do you think we always capitalize the word "Admins"?

Flow is powerful, and frankly it can sometimes be easy to forget just how powerful it is. So you’ve finished that Flow that updates a Case from a custom object. Why stop there? You could update that Account field which tracks your overall Case status, make a Chatter post, send a Task to a manager to follow-up, and make a new Idea record, all with one click.

Obviously, you won’t necessarily want to go crazy with it. THE major hallmark of a solid project is a clearly-defined scope, and in any project your goal should be to stick to that scope. But thinking along these lines can help you to plan ahead of time, to (quite literally) go with the Flow. On more than one occasion, I’ve found myself listening to the request of a director or manager, and the more I think about all the different ways in which their department touches other departments, the more ways I find to connect the objects through synchronized cross-object data updates. Those connections create extra value in your system, leading to easier reporting and more complete data!

4. Install the Getting Started Pack (and filter out most of it)

vfw-appexchange

On the AppExchange, you’ll find a hidden gem from Salesforce Labs called Visual Workflow Getting Started Pack. My advice: get this installed as soon as possible. Even once you do, you’ll have to sieve away a good amount of what is included to get to the gold nugget inside. That nugget is a little Apex plug-in that lets you send emails from Visual Workflow, an invaluable tool for communication in any organization that hasn’t fulled embraced Chatter or is trying to reduce Chatter clutter.

The one problem with this pack is all of the other things that come with it. There are a few other plugins that may or may not see any use, and a lot of sample plugins that, quite honestly, cease to be of any use after a certain point. Do yourself a favor and make a Flow view that filters out all the flows you no longer need.

5. Think Outside the Flow

biggerpicture

I absolutely ADORE Flow like it was one of my children, but even the most loving parent should be aware of their loved one’s limitations. It is but one tool in the toolbox, and as powerful as it is, it’s no good at things like simple math or formula functions (e.g. LEFT, YEAR, SUBSTITUTE). You want to include the year of the created date in the name of your newly created record? Sorry chum. You want to create a Task, but you want that due date to be two weeks from the date the user specified in the Flow’s Screen questions? Good luck.

BUT there are ways of getting around those limitations. The key is to remember that Flow is but part of the Wide World of Salesforce, and it can interact with the other parts. Let’s look at the first problem: somehow parsing out just the year of the created date.

  1. Set up a workflow that fires off when this type of record is created. Make it perform a Field Update that does the concatenation onto the record name, pulling whatever naming data you need. You can easily do the YEAR method on the CreatedDate as part of your Field Update; it’ll calculate it on the fly for you.
  2. If a user creates the record manually, you can still have this apply. Just be sure to tell your users that the Name field will be filled in automatically, but because it’s a universally-required field (being a Name field core to all Salesforce objects), they’ll have to put something in before hitting Save. Anything will do. Hit the letter A and call it good. It’ll just get overwritten by your Workflow, as it should!
  3. If you need it to only do this update on records created by the Flow, create a new checkbox field (not on any page layout, your users don’t need to be able to mess with this one!) called Generated by Flow. Have the Flow mark this as True when it runs, and edit the Workflow rule so that it only goes off when Generated by Flow is True.

See? We’ve combined Workflow and Flow seamlessly. Now let’s look at the other problem: adding days to a date specified during the Flow.

  1. Get the date from the user in a Screen. Simple enough.
  2. Immediately do a Record Update after the Screen, pushing the entered date into a new field. (Again, you can simply not put this on a page layout, if users don’t need to see it and you don’t want them tinkering with it after the fact.)
  3. Here, you can go two different ways. You could A) make Workflow that created a Task and added the time as needed, or B) create a new formula field that simply does the addition of the days to that given date.
  4. Make a Record Lookup to pull that formula field back into your flow, and make your Task as needed! (Remember that Tasks created with Flow can be assigned to a dynamically-determined user, rather than being stuck on a single name like Workflow does.)

Because Flow runs in order and doesn’t have to finish to do its work, your data can hop in and out of Flow! Anything that you can’t do in Flow, you can pass outside to the tools that CAN. Then pass it back and it’s like automagic!

The key in all of this is to make Flow work for you. The possibilities are nearly endless, and often it’s just a matter of figuring out the right path. Unless you’re talking about firing Flow without a button or link, don’t EVER let yourself think that something can’t be done in Flow!

P.S. Document and Communicate Like Your Life Depends On It!

OH one more thing! As a good admin, what should you do every time you release new functionality or replace old functionality? And when you release a new Flow, aren’t you usually releasing new functionality or replacing old?

The same thing applies here. ALWAYS document your new Flow, distribute that documentation to all relevant users, and do training/Q&A sessions to ensure that your users are properly able to use what you’ve given them. I’m not always the best at this, like a lot of admins, but I can tell you firsthand that the surest way to letting your users believe that you just sit and twiddle your thumbs all the ding-dong day is to not tell them what you HAVE done. Plus, you’ll alleviate the eventual head-hit-desk migraine and drive-to-drink, that you’ll undoubtedly encounter when you find that they’re using your carefully-crafted  tool in entirely the wrong way.