Bracket Labs delivers elegant, pain-free enterprise apps through the Salesforce AppExchange.  Our products help thousands of users plan & manage their work, share it with their teams, and increase revenue & decrease costs.  Learn more about TaskRay and Campaign Calendar.

Task Dependencies

What do these three scenarios have in common?

  • The Sales Fulfillment team requires a signed contract prior to shipping the product.
  • The Accounting team requires reconciled bank statements before closing the books.
  • The Marketing team must create content prior to sending an email campaign.

Each of these distinct departmental business processes require the completion of one task before another can begin, otherwise known as task dependencies. As you can imagine, this is a feature question we often hear for TaskRay. The great news is with the power and flexibility of the Salesforce platform, dependent tasks are natively supported.

Here's a walkthrough to show just how easy it is to set up dependent tasks in your TaskRay implementation (this assumes you have admin permissions in your Salesforce instance - if not, show this blog post to your admin).

Step 1: Add the Dependency look-up relationship

  1. Navigate to Your Name | Setup | Create | Objects | TaskRay Tasks.
  2. Scroll to the Custom Fields & Relationships section and click New.
  3. Select Lookup Relationship and click Next.
  4. Select TaskRay Task for Related To field and click Next.
  5. Change Field Label, Field Name & Child Relationship Name to Dependency and click Next.
  6. Manage profile visibility and click Next.
  7. Click Next to add to Page Layout.
  8. Change Related List Label to Dependent Tasks and click Save.

Step 2: Add the Dependency field to the TaskRay Task Field Set

  1. Navigate to Your Name | Setup | Create | Objects | TaskRay Tasks.
  2. Scroll to Field Sets section and click Edit next to TaskRay Task Field Set.
  3. Drag Dependency field into Field Set.
  4. Click Save.

Step 3: Add a Validation Rule to catch Dependent Tasks

  1. Navigate to Your Name | Setup | Create | Objects | TaskRay Tasks.
  2. Scroll to Validation Rules section and click New.
  3. Name the rule Dependent_Tasks and set it to Active.
  4. Enter the sample error condition formula as outlined in the snipped below.
  5. Enter this sample Error MessageThis task cannot be started until the dependent task is complete.
  6. Click Save.

Error Condition Formula

AND( 
OR (ISPICKVAL(TASKRAY__List__c,"Started"),ISPICKVAL(TASKRAY__List__c,"Finished")),
NOT (ISBLANK( Dependency__c )),
NOT(ISPICKVAL(Dependency__r.TASKRAY__List__c, "Finished"))
)

Step 4: Watch it work

Salesforce Visual Flow and TaskRay Walkthrough - Part 3 - Advanced Topics

This is Part 3 of a series on using Salesforce Visual Flow to automate the creation of TaskRay projects and tasks. Part 1 and Part 2 were previously published.

So You Think You Can Flow?

In Part 2 we covered how to build a basic flow that automates the creation of a TaskRay project from the Account object. This project is then populated with a number of TaskRay tasks, and all of the records we created were correctly labeled and related to the Account.  With the basics out of the way, now's the time to start dreaming big. This section is all about reveling in the complexity (and advanced functionality) of the visual flow we demo'd in Part 1.

The biggest request that I get is for relative dates - to set a task to start a week after the button is pushed or two days after the project starts, for example. It sounds easy, but at first the only answer I could work out involved adding new fields and supplementing my visual flow with a workflow rule. You see, one of the odd limitations of flows is that you can't create formulas using dates or set values as MM/DD/YY + number. The answer, as it turns out, is in using the Assignment element. We start by creating a date variable we can manipulate during our flow and setting its default as the current date.

Creating a date variable

Creating a date variable

Now any time we need to specify a date value relative to another date, we just use our new favorite variable. My flow actually starts with an Assignment element, because I want to specify a Project End Date two weeks after the project is created.

Creating a Visual Flow Assignment element

Creating a Visual Flow Assignment element

Three things to keep in mind:

  1. The "Value" you provide will adjust days, rather than hours, months, or years.
  2. I set a default value for varDate when I created the variable so I'm adding two weeks to the CurrentDate when the flow is run.
  3. You can pass in other dates - an Opportunity Close Date, for example - to serve as your starting point instead.

As you need to change the variable throughout the flow, create new Assignment elements. Just keep in mind that you're always adjusting the most recent value for the variable, not the default or starting value. I grouped my tasks by Deadline and adjusted the variable's value to reflect the number of days after the Project Start Date each task should be due.

Multiple Assignment elements

Multiple Assignment elements

Another common request is choose among several template options based on criteria in a related record. For example, say you want to create a project with follow-up tasks for your sales reps every time an Opportunity is closed. The individual tasks, however, need to vary first based on whether the Opp is Closed Won or Close Lost and secondly on the value in a custom Closed Lost Reason field you've created. In this case we use a Decision element:

Creating a Decision element

Creating a Decision element

After you give the element a name, you create "Outcome" values. This is a little bit deceiving, because these are not Outcomes in the sense of what happens after the decision. Think of it as asking the flow a question, like "What is the Opportunity Stage?" Then you tell it what the possible answers (Outcomes) might be. In my case, I only care about three possible answers: Closed Won, Closed Lost, and everything else. Once you've created your Decision, you continue by connecting this element to the rest of your flow in the same way we connected all the other pieces. The only difference is that you can connect a Decision to multiple actions, one for each possible outcome. Once you've created the connection, a lightbox will pop up asking you which Outcome to associate with that action.

You can use these to decide between entirely different project templates or you can choose between a certain task or group of tasks. Or both! You can certainly use multiple Decisions in a single flow, but if you do, just remember to take the time to think things through first. It's always better to have only as much complexity as you need and as much simplicity as you can manage!

We're getting close to the end, but I want to close this post with four last notes:

  1. Screen elements: You probably noticed in the last video that my last Outcome directs the user to something called "Screen." I used it to display a message to my users when they create a project before the Opportunity is closed. It's how I addressed the question "What if the Opp Stage isn't Closed Lost OR Closed Won?" but you can use it for a lot of purposes. The Screen element lets you collect additional information from a user as well as display it. If you want to use a template flow but need the user to answer a few questions first, consider starting with a Screen element. You can ask your questions, assign the answers to a few variables, then let the flow do its magic! If you collaborate with a developer, you can incorporate Visualforce pages in a Screen element for an even better user experience.
  2. Record Lookup/Update: Say you want to use the information you passed in from an account to look up a specific Opportunity or you want to use some of that useful information you gathered with your Screen element to look up a specific Contact. No problem! Add a Record Lookup element to find additional information and pull it into your flow. Maybe instead you have a custom Related Project field on the Account object, and you want to make sure the newly created project ID is added to the related account record automatically. No worries! Just add a Record Update element to make sure all your records are connected and nothing gets lost.
  3. Connections: Although Decision elements are the only action that can branch outward to multiple actions, all of the elements can receive multiple in-coming connections. For example, say you need to adjust a value differently based on the Outcome of a Decision you've created. Don't fret! You can connect both Assignment elements back to a single Record Create action.
  4. Fault Handling: The more your flow relies on user input or values that are not systematically required, the more you need to pay attention to error messages and fault handling in visual flows. I haven't used them much yet, to be honest. I have, however, received my fair share of "Unhandled process fault" emails from FlowApplication while in the process of building and testing my flows. When you get these messages, focus on the middle two sections. The second line tells you what happened and which fields were involved, and the third line tells you which element in your flow caused the problem. What do you do when this happens? Start by double-checking the data. Did you update or mistype the variable name? Does the flow variable come before the merge field in your URL? Did you correctly configure the variable that's receiving the information? Did you match the appropriate value to the right field when creating your record? If the error occurs after the flow's successful debut, double check that none of your object or field names have been changed.

I hope you've found this walkthrough a helpful starting point as you venture into the wonderful world of Salesforce flows. I've included some links to additional resources to round out your education below.

If you have any questions or need additional help - or if you just want more information about TaskRay, click the Feedback link in the upper right of TaskRay to send us a note or drop us a line on Twitter using @bracketlabs.

Salesforce Visual Flow and TaskRay Walkthrough - Part 2 - Build the Flow

This is Part 2 of a series on creating Visual Flow in Salesforce. Part 1 is here

Gather Your Ingredients

Now that we've thought through what we want to happen and what information we're using, let's get started. No, I mean, literally. Go to Setup / Create / Workflow & Approvals / Flows and click the New Flow button. Great! Just a friendly word of warning: though it's been working in Chrome lately, sometimes I've had to change browsers altogether and run the Flow Designer in Firefox.

Once the designer is loaded, look at the sidebar on the left. You'll see three tabs: Palette lists all the action elements for a flow, Resources lists all the data elements, and Explorer shows you the parts you've already created. I recommend starting with the Resources and getting your variables created first, just like gathering all your ingredients before you start cooking. You don't have to do it, but it does make the process a little less hectic.

In the Resources section, you'll see a Create New list. Double click on Variable and fill out the lightbox. We're only going to create four variables, one for each of the fields populated by the system. Salesforce recommends using a consistent naming convention to help you keep it all straight, and trust me, it helps a lot! I like using the prefix "var" and copying the field name, so my variables look like this:

varAccountName
varAccountID
varAccountOwnerID
varProjectID

Remember, we're not providing actual values right now (you can think of this part as creating a custom field for your flow). Most of the information is pretty straight-forward, but a couple of the options are a little confusing:

  • The one place I've been tripped up with Data Type is when I'm creating a variable for some sort of record ID. Remember that Salesforce-generated IDs use a combination of letters and numbers which makes them text strings, not numbers, in flow variables.
  • Input/Output Type tells the flow whether it's going to receive this information externally, pass the information back to the user, or both. If you're not sure, err on the side of "Input and Output."
  • The Default Value field at the bottom lets you specify, well, a default value if none is provided, but I use it only rarely.
Default Value field

Default Value field

Creating a Masterpiece

Now we head to our Palette tab, where things start to get more exciting. My flow is basically a series of Record Create actions, because I want to create a new TaskRay project with a set series of tasks. I need the flow to create my Project first, because I'm going to need to associate the new project's ID with all of the tasks I create next. Start by dragging the Record Create element onto your palette (anywhere in the top left will do), then fill out the lightbox that appears:

  1. I use a similar naming convention whenever I create my action elements for the flow, so my record name will be "createProject." I use prefixes that describe the element, just to keep things easy to follow. The system will automatically create the "unique name" for you.
  2. The Assignments section is where the real magic happens. First, I tell it that I want to create a new record for the custom object TASKRAY__Project__c, then I get to define the values for any of the fields on the record.
  3. Let's start with the basics: Name and Owner. Start typing Name in the first box, and select it when it appears in the drop-down list. Click the Add Row link below, and do the same for Owner.
  4. Now we're going to fill in the boxes to the right of each field with the desired values. I want my project name to display as a concatenation of Account Name + Messages Checklist, so I select varAccountName from the list then type Messages Checklist (no plus signs or quotes necessary!). I also want my Project Owner to be the same as the Account Owner, so I select varAccountOwnerID in the next box. You could, however, pass in the CurrentUserID instead, or even assign the task to a specific user every time.
  5. The last thing we have to do is store the Project ID created for this record, so we assign the value to our variable varProjectID.
Visual Flow Record Create form

Visual Flow Record Create form

Now we're going to do the same thing, but for a task. Again, start by dragging the Record Create element onto the palette. It doesn't really matter where you put it, but as your flow gets bigger, it helps to have some sort of organization to keep all the pieces straight. I'll show you what it looks like:

Note that I didn't assign the record ID to a variable for the task record, because I won't need to use that data later in the flow. Now, take this basic idea and repeat it for each task you want to create. You can also fancy it up a little and specify more fields. I'll show you what the same element might look like with additional fields listed:

Visual Flow Record Create with many fields

Visual Flow Record Create with many fields

The Name, OwnerID, and Project fields are all the same, but I've added some extras:

  • The Task Deadline field is a favorite, but relative dates in visual flows require some fancy footwork. We'll cover that in Part 3 under advanced topics.
  • Description can be a convenient field to use on a Task if it's always going to be the same. You could also take an Account Notes field, for example, and pass that information into the Description value (especially helpful for the Project Description!).
  • The List field is used by TaskRay to assign a task to one of the "Status Lists." I often use this for the first couple tasks, so that I can put them straight into the Prioritized column. If you don't assign a list, the tasks will automatically be put in Holding.
  • The Sort Order field is used to assign the order of tasks in a list, so if the order of operations is important to your project, you might consider using this field. Just remember that that if you're using the List field too, you order the tasks within each list individually.
  • Related Account is a custom field I added to the the Project and Project Task objects so that I can associate my projects and tasks with a specific account and move between them easily. I'll use the Account ID passed in by the custom button as the value for this field.

I know creating all your tasks with eight or more fields is a less than exciting prospect, so here's some good news: the Flow Designer lets you clone elements. Once you've created one Record Create element to your satisfaction, select it (so that it's outlined in green) then click the Copy icon in the toolbar. Use the neighboring Paste icon to give you a head start on all the rest of the tasks in your template! If you're creating some thing more complex, you can hold down the Ctrl (Windows) or Cmd (Mac) key to select multiple elements at once, making it quicker and easier to copy and paste or move around entire portions of your flow simultaneously.

Once you've built out your basic template you have to do a couple more things:

  1. Tell the flow which element is your starting point: When you hover over your first action element, you'll see three icons in the top right corner. The pencil opens the Edit lightbox, the trashcan deletes the element, and the green circle identifies the element as the first action in your flow. Click the green icon; it should show in the top right even when you move your mouse away from element.
  2. Connect your elements in the order you want the flow to proceed: Click and hold on the small triangle at the base of your first element and drag your mouse over to the next action, then release. A gray arrow should appear, connecting the two elements, and indicating the direction of the flow. Continue until all your actions are connected.
  3. Save your visual flow, then close the Flow Designer. You'll return to the page listing your flow's details, including the unique URL we'll need to set up our custom button. Before we go any farther, though, scroll down to the Flow Versions section of the page, and click the Activate link to the left of your flow.

It's worth noting that once you've activated a flow, you'll have to save any changes as a new version. The Save As lightbox provides a description field that lets you note the changes specific to each version, a feature I've found handy in tracking my work. Whenever you're ready to run your new version, don't forget to deactivate the previous version and activate the new one (only one version of any given flow can be active at a time).

Make It Work!

Most of the visual flows I've written to interact with TaskRay are triggered using a button on an object's record detail page, usually on Accounts or Campaigns. In case you've never created a custom button on a standard object, here's the super-quick summary! Find the object under Setup / Customize, then look for the Buttons and Links option. Click the New button next to Custom Buttons and Link. The page should look something like this:

Creating a cCustom button on an object

Creating a cCustom button on an object

The Label is the text that will show on the button itself, so try to think of something both descriptive and concise. You can see the selections I have made for Display Type, Behavior, and Content Source, but feel free to experiment with different settings.

I'll provide a quick overview of the anatomy of a URL, since it's just a little different from the way parameter passing tends to look in Salesforce:

  • /flow/Project_Template? - Remember when I pointed out the unique URL provided on the flow's detail page? Well, that's where this first part comes from. You can literally just copy and paste it! The question mark that comes next just indicates that the parameter passing is about to begin.
  • varAccountID={!Account.Id}&varAccountName={!Account.Name}&varAccountOwner={!Account.OwnerId} - This middle portion is what we've been calling "parameter passing," and it just means that we're taking information from the record where the button is located and passing that into the location indicated in the URL. For us, that's our flow. Remember that we're only passing over the information we decided on earlier, the specific data we need for our flow. Each parameter is separated by an ampersand and is written as [flow variable name] [equal sign] [merge field], like varAccountID={!Account.Id}. The good news is that Salesforce will create the merge field for you, so all you have to remember are the names of your variables.
  • &retURL=https://taskray.na9.visual.force.com/apex/trmyboard - Because my flow works entirely in the background, I want the URL to direct my users to TaskRay where they can see their newly created projects - and get to work immediately (evil chuckle)! You can leave off this section (and the preceding ampersand), or change the return URL value to something else entirely.

Once you've saved your new button, add it to the relevant page layouts and test it out.

Congratulations, you've just built your first visual flow and created a button to trigger it. You can use these same techniques to build this automation functionality across any number of objects. And if you're anything like me, you'll quickly want to start making them more sophisticated. In Part 3 we'll cover some advanced topics for making your Visual Flows more, well, advanced.

Salesforce Visual Flow and TaskRay Walkthrough - Part 1 - Intro and Planning

Visual Flow is Different

I have to start with a confession. The first time I created a Visual Flow, it took me a ridiculously long time to complete; I just couldn't get it to…work. And not only did I have Google and a nifty Salesforce workbook to help me out, I'd even attended the relevant Hands-on-Training at Dreamforce last fall.  Before you start panicking, let me share the good news: I was confused and stressed and panicked, so you won't have to be. I'm going to share some secrets that will help you skip the craziness and get straight to productivity.

Visual flows are different. They are not just an amped up version of workflow rules. Moreover they weren't developed by Salesforce in the first place, so the underlying logic is a little different. That's the biggest barrier to entry, in my opinion. Before we go any farther, you have got to let go of all your entirely reasonable assumptions and allow yourself to start with a blank slate.

That said, I should back up a little: How are flows different from a workflow rule? Workflow rules (another favorite of mine) allow you to set criteria that will automatically trigger certain activities, like field updates and email notifications. Visual flows - well, there's nothing automatic about flows, and that's probably one of their biggest limitations. Someone, somehow, has to start a visual flow, whether by navigating to a starting page or clicking a custom button. On the other hand, flows allow you to make cross-object changes you could never pull off with a workflow rule. Additionally, visual flows are intended to be interactive which means they not only allow you to insert new information, they expect it.

A Little Planning Never Hurts

Before we jump in, we should take a few minutes to prepare. This can be a little hard to explain, so I'm going to use my own project to guide the conversation. I'm creating a flow, triggered by a custom button on the Account, that will create a project to help a customer through the process of creating a new email campaign. This is a standardized process of six steps that a customer success manager will execute. Before we go any farther, check out the video below for a demo of the final visual flow in action.

Pretty fabulous, right? It's all there: the owner, the account, names and descriptions, the order the tasks should be worked, deadlines, even the start and end dates for the project itself. And in case you didn't notice, the project name is based on the Account Name. This is all possible because Visual Flow is not subject to the same cross-object limitations that govern workflow rules.  So let's get back to building it!

The first thing you have to do is think through the fields you'll be using and how you'll be using them. Who's populating them? You or the system? Will they vary by record or always be the same? I'll be interacting with fields on the Account, Project, and TaskRay Task objects (note that TaskRay Task object is named Project Task in the database and this is the name your Visual Flow will use):

FieldObjectPopulated by SystemPopulated by Me
Account NameAccountYes 
Account IDAccountYes 
Account Owner IDAccountYes 
Project NameProject Yes
Project IDProjectYes 
Project Start DateProject Yes
Project End DateProject Yes
Related AccountProject Yes
Task NameProject Task Yes
Task DescriptionProject Task Yes
Related AccountProject Task Yes
Status ListProject Task Yes
Sort OrderProject Task Yes
DeadlineProject Task Yes

The question of who is populating the information is a little tricky. It's really a matter of whether the system needs to remember the data for some reason. For example, when I write the URL for my "New Project" button, I'm going to ask the system to store the Account Name, ID, and Owner so I can use it later. Because I'm passing information into the flow, I need something inside the flow that can receive and house that information until I need it. The Project ID is similar, even though it will actually be created during the flow, because I have to remember that ID long enough to apply it to each of the related Project Task records I create.

Now that we've planned out how we want Visual Flow to interact with our object we're ready to start building. We'll cover that in Part 2