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!

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!

 

Admin’s Best Friend, Part 2

keep-calm-we-re-back

Aaaaaaaaaaaaaaaaaaaand we’re back.

In case you missed the last post, we are discussing the advantages of Visual Workflow, or Flow, over other Salesforce automation tools. Also, if you missed the last post, you can, y’know… scroll down. It’s still there. Oh no, don’t worry, I’ll wait.

Just in case your scroll wheel is broken, here’s a quick refresher? We covered that Flow can:

  1. Create Records – One of the only bits of Salesforce automation that can create a record, and it can create more than one at a time too.
  2. Perform If, Then, Else functionality, with Nesting – Branching logic that can make different things happen based on looking up data in Salesforce.

So now let’s move on to…

3. Work with Objects and Fields that Workflow Cannot

Ever wanted to do cross-object workflow from Case to Contact? How about workflow that creates an Event instead of a Task? Workflow that filters based on what department the User is in? Workflow that creates tasks with the owner being retrieved from a User lookup field? Workflow that makes a Chatter post? Workflow that refers to the Record Owner’s manager? Workflow that can do something as FREAKING SIMPLE as fill in a lookup field? (This is a personal point of frustration for yours truly.)

Welcome to the wild, winsome, wicked, and wonderful world of Flow.

Flow can access data from any point in Salesforce, provided you can give it a frame of reference. And it can create data anywhere as well. It can create any type of record, including some that aren’t quite obvious, like Chatter posts, Private Messages, Contact Roles, Case Team members, Opportunity Team members, Account Team members, Public Groups… The list goes on and on.

Within all of the objects available, you can create data and filter choices based on data you wouldn’t have been able to access otherwise. Not only can you access any data in the system to determine your actions (e.g. only creating a record if the Salesperson who clicked it is in a certain territory), but you can use it to access other data that workflow would normally be able to access, but just can’t. Have you ever tried to use workflow to populate the email of the $User’s manager for an approval process? I have. You can’t do it. Not without visual workflow.

Nope, no Manager >> present. I had to make the Manager Email Address field!
Nope, no Manager >> present. I had to make the Manager Email Address field!

4. Make a Single Click into a Workhorse Woolly Mammoth!

Each non-code automation tool in Salesforce has its strengths and weaknesses. Workflow can be chained to run one after another, but using it to move large amounts of data becomes cumbersome and unmanageable. Custom URLs can create records, though they can only do it once. But what if you wanted to do all of those things?

As far as I have found in my work, there is no upper limit on what can be done in Flow. I mean, I’m sure there is a limit SOMEWHERE, but I have yet to hit it, with my wild and woolly adventures therein.

As an example, let’s say you wanted to clone a record 5 times, bringing over 30 fields into the clone each time. Now let’s say it’s a DIFFERENT 30 fields in each clone. Sure, this is a pretty wacky hypothetical that generally falls beyond the realm of what one might ACTUALLY be asked to set up, but I have been asked to set up things that are not too far off. With workflow, you could have the fields populated when the records are created manually, but you’d have to set up 30+ field updates, one for each field that gets brought over. With a custom URL, you would need 5 separate URLs, as you could not create multiple records nor implement the branching.

skyrimmammoths

5. Automate / Drive / Force Process

To be fair, other kinds of button-click automation are also quite adept at providing this kind of service. But stop. Close your eyes. Think about driving process (or as Salesforce evangelist David Schach refers to it, “forcing function”), and think of all the things we just talked about.

Ok, yes, you can open your eyes if you need to go back and read what they were again.

Flow presents, by default, a Wizard-type interface. But what if it was your only method of making something happen?

  • What if you locked down your Opportunity’s Stage field and required the user to click a Flow button to make a change? You can filter it down different paths: if they’re changing the stage to Negotiation, you can ask and require certain information which then gets pushed into Opp fields, or if they’re changing it to Closed Won, you can require different information and even generate other records based on that, like tickets to setup your customer or other custom object records.
  • Do the same thing for Case Status, where if the owner is on your Retention team, you can require him to put in 3 dates for scheduled follow-up calls, and then create those Events for him!
  • Turn your User creation into a guided wizard process, to be sure that every step of the process is covered. (Because we Admins have a TON of things to think and worry about every day, and sometimes those little details just slip our minds, don’t they? Plus it can be a huge time-saver!)
  • Require that a date field be updated through a Flow (I’ll go into this in an upcoming post) so that the date field’s value can be copied into another record in another custom object. If these custom objects are not Master-Detail, you won’t be able to use regular Workflow for those!

flexidrive

When you can drive your Users to work down certain paths:

  • You minimize the demons of procrastination, obstinance, forgetfulness and human error.
  • You ensure a higher standard of work and customer interaction.
  • You ensure higher data quality.
  • You ensure quality metrics and analytics.
  • And you then become able to give your executive team whatever data they need without worrying about how reliable the data is.

Don’t think of it as being authoritarian or restrictive; think of it as ensuring job security for yourself.

Because when you become indispensable to your executives, they’ll do anything to keep you, and keep you happy! And Visual Workflow brought you there. I’d say that’s a tool worth learning, wouldn’t you?

Check it out! Joe Executive likes the cut of our jib! Eiffel Tower.

Check it out! Joe Executive likes the cut of our jib! Eiffel Tower.

Admin’s Best Friend, Part 1

Every admin has a favorite tool in Salesforce. Some live and die by the Data Loader, some have a passionate love affair with Workbench, and some have even made their own custom tools to make their Salesforce lives easier. But me… my best Salesforce friend is a little thing called Visual Workflow, or just Flow for short.

Now I know what some of you may be thinking. “Visualforce? That’s code right? I don’t do code.” Whoa whoa. Nay nay. Visual it may be, but Visualforce it is not. This is an entirely different beast, my friends. And while this beast may be intimidatingly big and hairy, it’s ridiculously helpful. It’s more like a workhorse, or pack animal. But big and hairy. So more like a woolly mammoth.

Look, the whole metaphor works if you just picture yourself as a caveman…

Image by David McCauley, "The Way Things Work"

Image by David McCauley, “The Way Things Work”

Yeah okay, let me start from the beginning.

Most admins are in one of two camps: the camp that doesn’t know what Visual Workflow is, or the camp that thinks it’s too difficult for them to use. And to a degree, that’s ok! Nothing to be ashamed of. The reason most admins fall into one of these two groups is because Salesforce, unfortunately, has not done a lot to change things to the contrary. They simply have not talked very much about Flow, and the past few Release Notes have been practically devoid of any Flow-related changes to grab your attention. They’ve released a few videos trying to explain the whole Flow thing, but because of its complexity, those videos’ approach of “Let’s try to cover as much about Flow as possible in 20 minutes” only means that they don’t really allow for much in the way of detail or absorption.

But we can change this, people! Flow is the key to unlocking a new world of workflow in your system. It will allow you to do automation in Salesforce you never dreamed would be possible without code. It is the true enabler of the “Clicks Not Code” philosophy, the game changer for the next generation of Salesforce. And this is one of the key focal points that this blog will circle around: to provide a series of articles extolling the virtues of Flow and making it easier to start using it in your instance.

geography-teacher-4

Alright, it’s teacher time. The first thing you need to know is what Flow can do. Some might say, “Hey wait, shouldn’t you focus on what Flow IS first?” Usually, I would say yes, but the key point here is that you know its worth. Flow can come across as complicated and having a high bar of entry, but if you’re aware of the crystallized AWESOME that it is capable of, you’re more likely to stick it out to the end. Trust me, it’s worth it. So what can it do that other tools cannot?

1. Create records

muffinbutton

Ever wanted to automatically create a new account, case, or other kind of non-task record using Workflow? Can’t be done, can it? Record creation has long been the domain of APEX and custom-URL buttons. NOT ANYMORE, MY FRIENDS.

Visual Workflow gives you not just the power to edit records, but to create and delete them as well.

  • Want a button that creates 4 pre-determined records with one click? You can do that.
  • Want a button that removes one opportunity product and replaces it with another? You can do that.
  • Want a button that can clone an Opportunity but will only pull over specific fields? YOU CAN DO THAT.
  • And the advantage it has over custom URL buttons is the fact that it can do multiple records at once, even if they are in DIFFERENT OBJECTS. MIND… BLOWN.

IT’S LIKE A BUTTON THAT MAKES MUFFINS. Except it makes records. Which is just as awesome but actually more useful. Unless you have a medical condition that prohibits you from eating any food that is not a muffin. That would be useful, then.

2. If…Then…Else (with Nesting!)

IF-THEN-ELSE-END_flowchart

Anyone with an coding experience will get what that is, but otherwise think of it like extremely advanced filtering for workflow. With regular Workflow, if you wished to do automation that could go down different branching paths based on different sets of criteria, you’d have to write multiple workflow rules, and you’d have a hell of a time trying to get multiples to interact with one another. If your filter criteria are in different objects, you’d just wash your hands of it.

But not so with Visual Workflow! Base your Opp workflow off of your Opportunity History! Create multiple branches that pass information down to the following automated actions, even if you keep branching and branching by more and more filters! Write automation that acts based on a combination of data in your records and questions asked of the user when they start the process!

This screenshot is but a sample from a live Flow running in our instance:

Sample - Priority Flag

You don’t have to get as complex as this in your Flow, but it’s a relief to know that you have the ability if it’s needed!

That’ll do for today’s blog post! Later this week, I’ll publish Part 2, explaining two more awesome button-click-exclusive capabilities of Visual Workflow and what it means when we get all these horses lined up and ready to run.

TO BE CONCLUDED…