Logo

Future-Proof Your Org w/ a Relative Salesforce Server URL

Salesforce Quick Tips Logo

Use A Dynamic/Relative Salesforce Server URL

Today, I’m going to show you how to future-proof your Salesforce server url.  Instead of specifying a specific Salesforce server, we will use a relative Salesforce server URL.  What does that mean exactly?  Well, have you ever created hyperlinks used in many email templates that point to a page within Salesforce?  Are they “hard links” that point to a specific Salesforce server, “https://na30.salesforce.com/” for example?

If Salesforce moves your org to a different server, you will have to go into each and every email template and make the change!

The Solution/Workaround – Relative URL’s In Email Templates

Create a formula field on the User object using the following formula:

LEFT($Api.Enterprise_Server_URL_270, FIND( "/services", 
$Api.Enterprise_Server_URL_270) -1)

Then, use this field whenever you need to reference the Salesforce Server URL.  If Salesforce moves your org to a different server, no changes necessary!

Do you have any other tips for future-proofing your org?  Post in the comments or message on Twitter!

Also check out the Go With The Salesforce Flow series!

Go With The Salesforce Flow – Using Multi-Select Picklists

Salesforce Flow Series

Using Multi-Select Picklists Within A Flow

Have you ever tried using multi-select picklists within a Salesforce Flow?  Did you update the picklist field with a new value and instead of adding the new value it replaced the existing value(s)?

I’ve found this to be a very unintuitive aspect of Salesforce Visual Flow.  If you do it wrong, you update the multi-select picklist field with new values, but wipe out the already existing values.  I have good news, however, because today I will show you a workaround!

Adding, Not Replacing, A Multi-Select Picklist Value In Flow

First store the existing picklist values as a multi-select picklist variable in your Record Lookup step.

Multi-Select Picklist Flow - Store Variable

Ensure the variable is set to “Picklist (Multi-Select)” data type.

Multi-Select Picklist Flow - Variable Type

Use a “Multi-Select Picklist” field within a Screen Element for users to interact with.

Multi-Select Picklist Flow - Choice Field

Create a new choice to be used as the default and set it to the variable that was set in the Record Lookup step.

Multi-Select Picklist Flow - Create Default Choice

Now create a new choice for every option you would like to provide your user.

Multi-Select Picklist Flow - Create Desired Choices

After you are done creating the necessary choices, ensure you set the correct one as the default choice as shown on the “Screen” image above.

Now create a Record Update step to update the desired multi-select picklist field from the value in the screen field.

Multi-Select Picklist Flow - Update Record From Multi-Select Field

 

That’s it!  But, what if you want to update using a different type of Screen Element field?  Check out below to see how you would update with a boolean field.

Create a boolean field.

Multi-Select Picklist Flow - Boolean Field to Update Multi-Select Picklist

 

Then, after creating a Decision step to determine whether the user has checked the box, create an Assignment step.  The Flow will utilize this step only if the box is checked.  Here, I’ve used another variable to store the record’s current picklist values.  Ensure that you use the “Add” operator and that you add a semicolon before the picklist value.

Multi-Select Picklist Flow - Assignment Add And SemiColon

Now add a Record Update step to update the picklist value with the variable’s value.

Multi-Select Picklist Flow - Update Field From Variable

 

Now we’re ready to run through the entire process!  Check out the Opportunity below.  The Multi-Select picklist field “Topics” currently has the values: Purchasing & Accessories.

Multi-Select Picklist Flow - Opp With Two Values Selected

Our Screen Element properly displays those as the two chosen fields, and gives use two available choices: Warranty & Service.

Multi-Select Picklist Flow - Add Two Values

I’ve gone ahead and added both of them and click “Next” in the flow.

Multi-Select Picklist Flow - Add Two Values

The Record Update takes place, and if I refresh the Opportunity, I now see the additional values were added to the two already existing values.  It didn’t wipe out what was already there…perfect!

Multi-Select Picklist Flow - Refresh Opp Values Added

Now, in my Flow I reach the boolean checkbox.  I check and click “Next.”

Multi-Select Picklist Flow - Use Boolean for Repair

Now when I refresh my Opportunity and click into the Topics field I see the following in the box and just below it.  All 5 values have been selected within the field and only “Replacement” has not been selected.

Multi-Select Picklist Flow - Opp Adds Repair

 

There you have it, we were able to successfully update a multi-select picklist within a Flow using two different methods & fields (one requiring an assignment step).  We successfully updated the values without removing or replacing the existing values.  Way to go!

Check out the rest of the Go With The Salesforce Flow Series for more Visual Flow tips & tricks!

 

Go With The Salesforce Flow – How to Default the Current Picklist Value

Salesforce Flow Series

Salesforce Flow – How to Default An Existing or the Current Picklist Value

Have you ever wanted to use a dropdown list within a Salesforce Flow Interview Screen and have it dynamically populate with the current value of that picklist field?  Well I’m here to show you how!

First, make sure you store the current value of the picklist field in a variable within a Lookup step in your flow.  Here, I’m storing/assigning the current Delivery/Installation Status value to a variable.

Salesforce Flow Record Lookup

Then, on the desired screen where you would like to present this information, add a “Dropdown List” field.

Salesforce Flow Add Dropdown List

Now, you will want to give your users a choice between all of the available values of that picklist field.  Hint: using this method to add a choice future-proofs your flow so that even when available picklist values are changed your flow won’t need to be updated!  Within the choice settings section, select “Picklist Choice.”

Salesforce Flow Add Picklist Choice

Now you will choose the Object & Field where you would like to pull the available choices from.  Notice the spelling mistake “Piclist Choice Settings” – c’mon Salesforce!

Salesforce Flow Add Picklist Choice

Now let’s quickly recap what we’ve accomplished so far.  We’ve taken the current value of a picklist field and stored it within a Flow Variable.  We’ve also added a Dropdown List field to an Interview Screen and populated it so that our user can choose from all of the available picklist values from the same field.  If we stopped here, we would be storing the current value in a variable, but the Dropdown List on the Interview Screen wouldn’t automatically default to the current value.  The user could choose from any available value for that field but would not have any way of knowing what the current value on the record is.  See, I can’t set the Default Value!

Salesforce Flow No Default Option

The key to selecting a default value is to create another choice, this time just a standard “Choice.”

Salesforce Flow Create Default Choice

Now this is where it gets fun.  Instead of typing a static Label for this default choice, we are going to use the variable we stored so that it will always dynamically display the text of the current value.  We also want the variable’s value to be the “Stored” value of this selection so that if we update the record from this Screen Choice Field the correct information will be passed.

Salesforce Flow Create Default Choice

Now we are able to set the Default Value of our Dropdown List to this new default choice.

Salesforce Flow Screen Picklist Field

Here it is in action!  We have an Opportunity that has a current Delivery/Installation Status value of “In progress.”  If we interact with this Opportunity via our Flow, we would expect to see this value already populated.

Salesforce Opportunity

Sure enough, “In progress” is the selected value within our Dropdown List field!

Salesforce Flow Defaults to Existing Value

One important note: this method will actually create two choices that are exactly the same.  We created a choice that contains the full list of all available values for this picklist field, and then we also have the default/current value.  As you can see below, you see “In progress” twice.  It doesn’t matter which one you select, this field would pass the same value!

Salesforce Picklist Duplicated

 

Stay tuned as our Salesforce Flow Series continues with more tips & tricks!

Go With The Salesforce Flow – The Basics

Salesforce Flow Series

Create A Simple Salesforce Flow – A Quick Guide

Let’s create a very simple Salesforce Flow.  This will be an “Interview” Flow which will require user interaction (because it contains screens for the user to interact with) that will be launched from an Opportunity button.  The Button URL will pass a Flow Variable (The Opportunity ID of the record we are on) so that when the Flow starts, it will know the Opportunity we are working with.  First, the Flow will pull some information from the Opportunity and store it in Flow Variables for later use.  Then compare the Opportunity Amount and determine whether it is a high dollar value Opportunity.  If it is a high dollar value Opp, it will give the user the option to create a Case that will alert a service team to assist with winning the Opp.  If the user decides to create a Case, it will automatically be associated with the proper Account.

Create A Basic Salesforce Flow

Locate the Cloud Flow Designer by navigating to Build –> Create –> Workflow & Approvals –> Flows or simply type “Flows” into the Quick Find box within Setup.

Salesforce Flow Menu

This page will list all of your existing Flows.  This is where you can manage each version (each Flow creates a new version each time you click “Save As”), and decide which to Activate.  Click the “New Flow” button.

Salesforce Flow Create New Flow

The top left side of the page is where you will find all of the elements you will use within your Flow.  In this Flow, we will be using Screens, Record Create, Record Lookup, and Decisions.  To add an element to the Flow, simply drag and drop the desired element onto the canvas.

Salesforce Flow Palette

The next tab contains Resources.  This is where you can create the variables, formulas, choices, etc. that will be used within the above steps/elements.  You can also create them while you are editing the above steps so I rarely use this tab personally.  It would be beneficial if you wanted to create all of your variables, choices, etc. in bulk first before you started building the Flow elements that used them.

Salesforce Flow Resources

First, let’s drag a Record Lookup Element onto the canvas.  The Record Lookup settings immediately open.  Name it, then you specify the filter criteria for locating the desired Opportunity.  In this case, we want to locate the Opportunity with the ID that we will pass in with the Button we create on the Opportunity record.  You will need to create a new variable for this data to be passed in from the Button.

Salesforce Flow Record Lookup

Because this variable needs to be accessed from outside the Flow (data passed in the button URL) make sure to set it to at least “Input” – and not “Private.”  “Input and Output” will work just fine too.

Salesforce Flow Variable

Now, select the fields from the particular record that you “Looked Up” that you would like to assign as a variable to reference within your flow.  In other words, assign the current value of that field to a Flow variable so that you can access it in the Flow.  In the example below, I’ve set the Opportunity Name & Amount to Flow variables.  Be sure to set the correct variable type – Number, Text, Currency, etc.

Salesforce Flow Assign Variables

After save, the canvas will be revealed again.  Every Flow must have a “Start Element.”  In other words, after you have many steps added to a particular Flow, you must indicate where the Flow should begin.  Hover over and click the green arrow to set this step as the Start Element.

Salesforce Flow Start Element

Now drag over a Decision step.  This is where you can add logical operators to impact the course of the Flow.  In this basic example, we are going to evaluate the Opportunity Amount and have two outcomes, Low & High.

Salesforce Flow Decision

Now drag a Screen element onto the canvas and give it a name.  A Screen is used to present and collect information from the user.  This screen will be used if the Opportunity has a High Amount as determined by our Decision Element we just created.  First give it a name:

Salesforce Flow Screen

Then, within the “Add a Field” tab we can drag over a “Display Text” Field.  Here we can reference variables to dynamically control the content.  Then, drag over a “Radio Button” Field and give it a name, and create two choices.

Salesforce Flow Radio Buttons

Here is an example of creating a new Choice:

Salesforce Flow Choice

Save this Screen and create another for the final Screen all users will be taken to upon completion of the Flow.

Now you can start piecing together the Flow and its order of operations.  First, connect the “Record Lookup” to your “Decision” element by clicking and dragging from one element to the other.  Then, connect from the Decision to the Finish Screen.  Because you are connecting from a Decision and there are multiple outcomes, a popup will appear and let you choose which outcome should follow the desired path.  In this case, we only want to take the user to the Finish Screen if the Opp Amount was Low, otherwise we want to take the user to our “High Dollar Opp” screen where we let them decide if they want to create a Case.

Connect from the Decision to the Finish Screen for “Low” Opps and from the Decision to the High Dollar Opp Screen for “High” Opps.

Salesforce Flow Decision Routing

Now drag another Decision Element to the canvas.  This time it will be used to evaluate the user’s input on the High Dollar Opp Screen, whether the user selected “Yes” or “No” to create a Case.

Salesforce Flow Decision

The last step is to drag a “Record Create” element onto the canvas.  If the user selects to create a Case, this is the step which will fulfill that choice.  Select the Object you would like to create a record of and indicate how to populate specific fields.  Here I’ve set a custom Subject, passed in the same AccountID as the Opp (stored in a variable) and selected an existing Picklist Value for Priority.

Salesforce Flow Record Create

Now the Flow should look something like this.  We lookup the Opportunity from which the button was clicked (the button URL will pass into the flow the Opportunity ID) and assign Flow variables to the current values of specific fields.  The Flow evaluates the Opportunity Amount and determines whether it is High or Low.  If Low, the user is taken directly to the Finish Screen.  If High, the user is taken to the High Dollar Opp screen where they are able to select whether to create a Case.  If they decide not to create a Case, they are taken to the Finish Screen.  If they select to create a Case, the case is created using a Record Create element.

Salesforce Flow Path

It’s best practice to create a Screen to display any errors that may occur within the Flow.  By default, any errors which may occur within the Flow (for example, a validation error upon a record create or update) will display a generic Flow Fault message that will not help us diagnose what went wrong.  By creating a Screen for errors, we can see exactly what went wrong and take steps to prevent it.  Drag another Screen element and then add a “Display Text” field.  For the text to display, use the “Resource” dropdown and select the $Flow FaultMessage.

Salesforce Flow Error Screen

Now, be sure that you’ve connected the “Create A Case” Record Create step to your Finish Screen.

Next, connect the Record Lookup and Record Create steps to the Error Screen.  Since those steps already have a next step path indicated, the Flow editor knows that this path will be utilized for any faults that occur within the Flow.  This is indicated by the word “Fault” in the connection to the Error Screen.

Salesforce Flow Path

Now, make sure you have saved your Flow and click the Close button.  You will be taken back to the Flow Detail page within the Salesforce Setup menu.  Take note of the Flow URL indicated on this page.  Click the “Activate” link next to the Flow version (if you have saved multiple versions using the “Save As” button) you would like to use.

Salesforce Flow Activate Flow

Now we are almost done!  Time to create a new button that will be placed on the Opportunity Page Layout.  Navigate to the Buttons, Links, and Actions page for Opportunities and click “New Button or Link.”

Salesforce Flow New Button

Name your button, select “Detail Page Button” and “Display in existing window without sidebar or header” and “URL.”  Now we will specify the URL that the user will be redirected by pressing the button.  This button should take users to the Flow and pass in the Opportunity ID.  Use the Flow URL that was listed on the Flow Detail page, and then type a “?” question mark.  Then, carefully type the name of the Opportunity ID variable we created in the Flow.  Next, add an “=” equals sign and then you can use the dropdown to select a merge field for the Opportunity ID.

Salesforce Flow New Button

Now save the button and add it to the desired Opportunity Page Layout.

Salesforce Flow Press Opportunity Button

Because I pressed the button on an Opportunity greater than $10K I am given the option to create a Case.

Salesforce Flow Opportunity Flow Screen

If I choose “Yes” – the Flow creates a Case for the same Account as the Opportunity as specified in the Flow.  Now when I open the Account, I see the associated Case.

Salesforce Flow Account Case

We Did It!

Give yourself a pat on the back!  You should be proud of yourself for following along!  This is a very simple example that only scratches the surface of the power of Flow.  I hope you find it helpful if you have never worked with Salesforce Flow before.  This simple example contains all of the basic building blocks that you can use to grow your Flow skills!  We will continue the series focusing on some less covered topics such as:

  • How to default an existing picklist value within a Flow (to its current value).
  • Set the finish location of a Flow embedded within a Visualforce page.
  • How to work with multi-select picklists within a Flow, retain current values and append or add new ones.
  • Workaround for a Flow interview that creates a new record that the running user only has access to based on sharing rules and the sharing rules haven’t taken affect yet!
  • How to share specific records automatically using an autolaunched Flow without sharing rules!

 

Go With The Salesforce Flow – A Salesforce Visual Flow Series

Salesforce Flow Series

Go With The (Salesforce) Flow

The Salesforce Cloud Flow Designer AKA Salesforce Flow is a powerful tool that allows you to build complex logic without writing any code.  It is the premier declarative development tool within the Force.com Platform.  It enables you to leverage Variables, Constants, Formulas and logical processes like Decisions, Lookups, and more to interact and update the data within your Salesforce Org.

Two Primary Types of Flows

Autolaunched Flow: This flow does not require any user interaction and can be launched automatically such as from a process or Apex.

Interview: This flow requires user interaction.  The flow can take different paths depending on the information the user inputs as they navigate through a series of screens.  This flow can run from a URL directly, be added as a button to any record page (run as a pop-up), or embedded within a Visualforce page.

What Can You Do With A Salesforce Flow?

A Salesforce Flow can accomplish a combination of anything a user could do manually with anything a workflow rule could do, and more!  Need to clone an account and duplicate all of its associated contacts, opportunities & contracts and automatically associate them with the new account? You can do that!  Want to guide a user through a series of screens in order to gather all the necessary information for a contract AND based on this info and data contained within the Account, Opportunity, and existing Contracts decide whether the new request can fall under an existing contract or a new contract is needed?  Once that decision has been made, it can automatically create the new records!  What if you need to manually share an Account & Opportunity (Read/Write) within a private sharing model, specifically to whichever user is input into a custom lookup field (Opp –> User)?  You can do this with an autolaunched flow!

Need to create a button on an Opportunity that will automatically close the Opp as Won, create a new Contract record with information from the Account & Opportunity, AND create a Case assigned to a specific service queue that will fulfill the sale?  An Interview Flow allows this!

Get Ready!

As you can probably already tell, Flows are a powerful thing.  We’ll spend some time getting you up and running if you’ve never worked with Salesforce Flow before.  Then we’ll really focus on some less covered topics such as:

We’re going to have lots of fun.  If there is anything in particular that you would like to cover, I would love to hear about it in the comments!

 

 

How to get the MAX or Most Recent Date of several date fields in Salesforce Formula

Goal: Return the MAX or Most Recent Date of several dates

Recently I needed to get the most recent date of 4 separate date fields.  I created a new formula field and was shocked to find that MAX(custom_date_1,custom_date_2,custom_date_3,custom_date_4) did not work.  MYSQL allows MAX() to function for date fields and I was surprised it didn’t work here!

Workaround: MAX(DATE) Formula

The full formula example of the workaround is below.  An important aspect of the formula is to handle if any of the dates that are being compared are null.  Also remember to add DATEVALUE() for any fields that are of type DATETIME.

IF(
    AND(
        ISBLANK(custom_date_1),
        ISBLANK(custom_date_2),
        ISBLANK(custom_date_3),
        ISBLANK(custom_date_4)
    ),
    NULL,
    DATE(1900, 01, 01) +
    MAX(
        BLANKVALUE(
            custom_date_1, 
            DATE(1900, 01, 01)
        ) - DATE(1900, 01, 01),
        BLANKVALUE(
            custom_date_2,
            DATE(1900, 01, 01)
        ) - DATE(1900, 01, 01),
        BLANKVALUE(
            custom_date_3,
            DATE(1900, 01, 01)
        ) - DATE(1900, 01, 01),
        BLANKVALUE(
            custom_date_4,
            DATE(1900, 01, 01)
        ) - DATE(1900, 01, 01)
    )
)

I hope you find this helpful!

Salesforce – let’s have a date…and time! Date Fields Missing Time Workaround

System Date Fields Missing Time

You can’t go on a date without first setting a time, right?  Well, Salesforce has found a way to have system date fields missing time information!  Have you ever wanted to know the created date & time of a record within Salesforce reports?  How about sorting a list view in ascending or descending order based on the creation or last modified date?  Well unfortunately, even though these date/time fields capture both the date and the time, only the date is displayed in reports and views.  Thankfully there is a quick and easy workaround for this issue as outlined below.

Date Fields Missing Time – The Problem

Date Fields Missing Time Without Time In Salesforce List Views

Where has the time gone? Definitely not found in Salesforce list views and reports!

Date Fields Missing Time Without Time In Salesforce Reports

Date Fields Missing Time – The Workaround

Create a formula field and be sure to select Date/Time as the type:

Create Custom Formula for Date Fields Missing Time Without Time

For the formula result, select the System field you would like to retrieve:

Set Created Date as Formula for Date Fields Missing Time Without Time

In this case, we are wanting to pull in the Created Date & Time info.

Set Created Date As Formula Result for Date Fields Missing Time Without Time

Add the new formula fields to your list views & reports and enjoy!

Dates With Times Now In Salesforce List Views

There’s the time!  Now you can easily sort in ascending or descending order!

Dates With Times Now In Salesforce Reports

 

What other tricks do you have related to date/time fields?  Let me know in the comments!

Multiple tabs are your Salesforce friends!

I’m sure you leverage multiple tabs in your everyday web browsing life, but have you utilized them in Salesforce.com?  No, I’m not talking about (my 3-year-old son says, “but but but that’s not what I was talking about!) the objects you add to apps to display in the tab bar at the top of every page within Salesforce.  I’m talking about using multiple browser tabs.  I’ve found them to be instrumental in day-to-day administration and configuration of the platform.

For example, I’ve opened multiple browser tabs to quickly compare 5 or 10 page layouts and quickly used the keyboard to toggle between them rapidly to ensure all layouts include/exclude particular fields with the correct access (read-only) and placement.  Sure, I could have used a single tab and used the Salesforce drop-down to select the next layout and repeated 10x, but opening them all up quickly and then cycling through is much faster.

Multiple Tabs – Profile – Object Permissions

While editing profile permissions, I’ve opened multiple a tab of each profile in question and quickly toggled between them to compare and contrast.  Sure, I do know that the enhanced profile interface would let me add a new view with columns for each CRED on specific objects and view those for whichever profiles I want.  But this is honestly a pain.  I can only have 10 columns and each CRED attribute (Create, Read, Edit, Delete, View All, Modify All, etc.) take up a column.  I can maybe get two objects within a view and that takes time to build if you are leveraging many standard and custom objects including managed packages.  Not to mention you can’t add page layout or record type assignments to these views.

Below is a quick example of this.  I was not able to use my keyboard shortcuts while creating the GIF, so I just cycled through with the mouse.  The key here is to learn the keyboard shortcut so you can toggle through much faster, and focus all of your attention on the text.  Any differences will quickly jump out at you!  Once you are done cycling through the current objects on the page, hit space bar on each tab as you cycle through.  It will scroll the window down by the same amount on each tab so that they all line up perfectly for you to continue your review.  In this case the only difference is the Tab for Leads is “Default Off” for the Support Profile.

Use Multiple Tabs to Check Profile Permissions

Multiple Tabs – CRED – Field Security – Page Layouts & Record Types

From here I can open up multiple tabs for various objects to edit/review or open the same object but for various profiles (example below).  Here I can quickly see CRED permissions, field security, and page layout & record type assignments and make the necessary changes.

Use Multiple Tabs to Check Assigned Page Layouts Record Types And Object Perms

Multiple Tabs – Available Picklist Values for Record Types

This also comes in handy when quickly reviewing the available picklist values for different record types.

Use Multiple Tabs to Check Record Type Available Picklist Values

Admittedly, these examples are simple and I wasn’t able to cycle through as fast as you can with the keyboard.  It may seem that you could just as easily accomplish a simple task with a single browser tab/window.  But what if you had 10 different picklist fields to compare for 10 different record types?  Using multiple tabs can help you quickly and efficiently review settings across the platform and make changes if necessary.

How do you leverage multiple tabs in your Salesforce Administration?  Would love to hear your comments!

Lead Users Through a Business Process with Record Types

AnimLeadRecordTypeConvertButton

Record Types Create Salesforce Magic!

Do you understand the basics of custom fields, page layouts, and workflows and want to reach the next level?

Maybe you have a well administered salesforce org with validation rules, but encounter the need for “walking” your users through a specific business process specific to your industry.

Look no further than record types! They are not as confusing as they may first appear.

Record types are just a clean way of associating a different page layout, stage/status, and customizing the available values on picklist fields.

Record Types Determine:

  • Page Layout – Display different layouts depending on the record type.  For example, a lead that was generated from a google ad could display very different fields and buttons compared to one manually entered from an inbound phone call.
  • Process – These are specific to the object, but some examples include opportunity stages, lead statuses.  The google ad lead above may not include a “working” status.  You can simply remove that option from the picklist.
  • Picklist Values – Just like you can control the availability of the stage/status picklist values above you can also do this for any other picklist field on the object!

LeadProcess

Lead Process Selection

Once you master these available options, add workflow to the mix for some real process magic.

Let’s say you don’t want to allow users to convert a lead until they have entered a specific set of information. You can set it up so that all incoming leads will be a specific record type with a page layout that does not include the “convert” button.  Then, when certain fields have been filled out, a workflow can fire to update the record type of the lead. The new record type will have different page layout for the specific user’s profile that will reveal the “convert” button.  See the animation below for this use case in action!

 

UpdateFieldRecordType
Setting Up The Field Update to Update Lead Record Type

AnimLeadRecordTypeConvertButton

Animation – Convert Button Not Present Until Specific Fields Entered