Visual Workflow Series Part 1: Use Visual Workflow to Share Records Dynamically

Sharing rules are a great way to make sure your records are accessible to groups of users (such as roles and public groups). Unfortunately, sharing rules cannot be used to share records dynamically, such as with a user in a lookup field on a record. Fortunately, this can be done declaratively using one of our favorite tools: Visual Workflow (with some assistance from its sibling, Process Builder!).

Our general approach to this is similar to the function of the Sharing button in Salesforce Classic – we will share a level of access to a specific record with a specific user. This is done through a separate object called objectNameShare for standard objects and customObjectName__Share for custom objects. As long as a share record exists for your user or for a group to which you belong, you’ll have that level of access on a record. Share records have 4 important fields that we’ll worry about:

  • AccessLevel : this is the level of access granted to the user (picklist values are Read, Edit, and All)
  • ParentId : this is the record ID of the record that is being shared
  • RowCause : this is the reason for sharing the record; for custom objects, custom sharing reasons can be created
  • UserOrGroupId : this is the ID of the group or user with which you are sharing the record

N.B. : for standard objects, the naming convention for these fields is slightly different; OpportunityShare, for example, uses OpportunityAccessLevel and OpportunityId instead of the above field. If you’re not sure what to use, navigate to the object in Workbench and click on the Fields folder for that record. Additionally, sharing is only available for objects where the sharing setting is not Public Read/Write.

Let’s get to sharing! Here’s our user story: our sales team often assigns a Subject Matter Expert (SME) on certain opportunities. These SMEs only need read access on the records they are assigned too, and our org does not use Opportunity Teams (see note). Our SMEs are discovering that they do not have access when they are initially assigned to the opportunity and the salesperson has to manually share the opportunity with the SME. Help the sales team share the opportunities with the assigned SME automatically!

First, we’ll create a flow that will create the sharing record. Using a record lookup block, we will look up an Opportunity where the ID is the same as the value we pass in through the process builder. We’ll call that variable OppVar (text variable, input only). We’ll store the ID of the SME in a variable called SMEVar (text variable, private).

Flow SME Share 1

Next, we’ll check to see if the user already has access to the record with another record lookup. We want to look up any OpportunityShare records where the UserOrGroupId is the same as SMEVar and the OpportunityId is equal to OppVar. Save the value of the OpportunityAccessLevel to a variable called Access (text variable, private). Make sure to check the box to Assign null values to the variable if no record is found.

Flow SME Share 2

Now that we’ve found any existing OpportunityShare records, we will add a decision block to check the value of Access; call that block “Does access exist?”. We’ll create an outcome called “Yes” where Access is not null. We can also rename the Default Outcome “No”.

Flow SME Share 3

Our last step for the flow is to create the share record if the decision block has the “No” outcome. We’ll give Read access, set OppVar as the OpportunityId, set Manual as the RowCause, and SMEVar as the UserOrGroupId.

Flow SME Share 4

We’ll save the completed flow as an Autolaunched flow so we can call it through Process Builder, activate the flow, and then create the process itself! We’ll create a process that runs when a record changes. Select Opportunity as the object and run the process whenever records are created or edited.

Flow SME Share 7

In the criteria, we’ll have this process run when the SME field is not null and changes values.

Flow SME Share 8

Our last step before activating is to add the Flow action. Select Flow as the action type, call the step “Share with SME”, and select your autolaunched flow. Set the variable OppVar to the value of the opportunity’s ID. Save the step and activate the flow!

Flow SME Share 9

Congratulations, you’ve accomplished your task! To test, you can populate the SME field on an opportunity, and then click the Sharing button. You can see a value for that user with Read Only access listed as Manual. Give yourself a pat on the back!

Thanks for reading the first post in our Visual Workflow series! Tune in next week for more on Flows!

Have another topic you’d like to see in the future? Send us a tweet! @BeardforceTyler

 

Chatter Groups: How to Create Your Own Collaboration Space

Salesforce Simplification header

One of my favorite features inside Salesforce is Chatter, the Salesforce platform for collaboration. Chatter helps users share information across the organization without leaving Salesforce, so everything is discussed in context directly on individual records.

Taking this collaboration one step further, departments and functional teams can collaborate within Salesforce by creating their own Chatter Groups with specific people. This allows users to share project-related or department-related files and information.

In today’s post, we will go over creating Chatter Groups.

Note: We are using the Lightning Experience desktop user interface in this post.

 Basics

Salesforce users can join up to 300 groups, and your organization can house 30,000 Chatter Groups. Plenty of space for team collaboration! In order to create new Chatter Groups, you must have the Create and Own New Chatter Groups user permission.

Groups blog post 1

You can also use the App Launcher to find Groups

Groups blog post 1.2

Groups blog post 2

Groups blog post 3

Groups blog post 4

Groups blog post 5

Groups blog post 6

Groups blog post 7

 

Thank you for reading our blog! If you have Salesforce tips or tricks you would like to see discussed, tweet @JessSFDC and let me know.

Until next time,may-the-salesforce-be-with-you-footer

 

 

 

Custom List View Series Part 4: Dynamic List Views

Over the last few weeks, we’ve reviewed how to create List Views in both the Classic Interface and Lightning Experience. Today, we’ll discuss creating a Dynamic List View that you can enable for all or some of your users to give them easy views that they might not be able to create themselves!

Before we start, a quick note: this example assumes that the users already have at least read access to the records that will be included in the List View. You may need to change the Org-Wide Default for the object or add Sharing Rules to open access to certain users.

Let’s get started! Your account managers have Subject Matter Experts (SMEs) who lead sales on complicated deals. This means that the SME will enter the Opportunity into Salesforce and continue to own the Opportunity until it is closed. When the account managers create a List View using My Opportunities, they are missing the Opportunities entered by the SMEs. Help them see all Opportunities on their accounts easily!

This is actually a lot easier than it sounds! We will use a combination of a formula checkbox and a List View to solve for this.

First, let’s add a custom field to the Opportunity object. We’ll choose the Formula field type and Checkbox Formula Return Type. Let’s call the field “My Account”.

dlv 1

Next, we’ll enter the formula. We’ll use $User.Id = Account.Owner.Id .

dlv 2

This formula will return a TRUE (or checked) result when the current user matches the Account Owner. If Jess Beauty owns an Account and Tyler Beard enters an Opportunity on that Account, the box would be checked when Jess looks at it, but unchecked when Tyler looks at it. Neat!

Our last step is to create the List View. We’ll select All Opportunities in the Filter By Owner selection and then filter by My Account equals True in the field filters. Let’s filter to a single record type too; that way the account managers can use inline editing. Select the fields you want to display and the users you’d like to share the List View with.

dlv 6

You’re done! Save and view the awesome new view you’ve given to your users. Now your account managers can easily see all Opportunities on their Accounts, even if they don’t own them!

This methodology can be used on any object as long as the user already has access to the records you would like them to see. We hope this post helps you think of new ways to create Dynamic List Views in your Org! Thanks for reading the fourth post in our List View series! Tune in next week for more!

Have another topic you’d like to see in the future? Send us a tweet! @BeardforceTyler

Custom List View Series Part 3: Charts and Inline Editing

salesforce-simplification-header

We first discussed list views in the Lightning Experience two weeks ago: Custom List View Series Part 1: The Basics & Filter Overview. Read up on that post if you’re just now joining us!

In today’s post, we will go over creating charts and inline editing.

Note: We are using the Lightning Experience desktop user interface in this post. Check out Tyler’s post from last week to see list views in Salesforce Classic.
Custom List View Series Part 2: Salesforce Classic Overview

Remember the “My Best Opps” opportunity list view? Let’s go back and add some charts.

List View blog post - 112This list view shows my opportunities in the Awaiting purchase order/LOI stage that are $50,000+ in addition to my opportunities from ABC Company.

2List View part 3 blog post - 1

2List View part 3 blog post - 2

2List View part 3 blog post - 3          2List View part 3 blog post - 4

For this chart, we want the sum of the opportunity amount grouped by Close Date and presented in a horizontal bar chart.

2List View part 3 blog post - 5

I need to make some updates to these opportunities, so a great way to easily do so is by inline editing. However, remember my list view filters and filter logic? It includes opportunities in the Awaiting purchase order/LOI stage over $50,000+ OR my opportunities from ABC Company. Because this list view has filter logic, inline editing is unavailable.

Let’s look at the My Open Opportunities list view. This is filtered by Stage and Opportunity Record Type – there is no filter logic.

Note: A list view must be filtered by a single Opportunity Record Type to enable inline editing.

2List View part 3 blog post - 6

Most standard and custom fields are available for inline editing. If a field is not available for inline editing, the lock icon appears. Data security rules apply, of course; users can only edit records they have Read/Write access to.

2List View part 3 blog post - 8

2List View part 3 blog post - 9

2List View part 3 blog post - 110

2List View part 3 blog post - 111

 

2List View part 3 blog post - 112

Thank you for reading my blog! Eager to learn more on this topic? Stay tuned for our multi-week series on list views – Tyler is up next week!

If you have Salesforce tips or tricks you would like to see in this blog, tweet @JessSFDC and let me know.

Until next time,

may-the-salesforce-be-with-you-footer 

Custom List View Series Part 2: Salesforce Classic Overview

Last week, we took a look at List Views in Lightning Experience. Since some organizations haven’t made the move to Lightning quite yet, today we will walk through List Views in the Classic interface.

Overview

Like in Lightning Experience, List Views provide an easy way to access data that meets certain parameters, similar to a report. Unlike a report, List Views can allow inline editing, certain actions through List View buttons, and a quick option to delete. If you have a set of data that you work with frequently, List Views are the way to go!

 Accessing List Views

We’ll use the Opportunity object as our example in this post. List views are available for any object that has a Tab, and are accessed by clicking on the Tab.

Toward the top of the screen on the Opportunity home page, you’ll see a dropdown list titled “View”. Using this dropdown list, you can select the view you’d like to access or create a new one. Let’s walk through creating a new List View.

lv1

Creating Custom List Views

Let’s create a custom List View for Opportunities that have not been modified in over 2 weeks and are not in the Closed Won or Closed Lost Stages so we can catch deals before they go stale!

When we click on the Create New View link, we’ll be directed to this screen:

lv2

First, we’ll enter a name: Stale Opps. The Unique Name will populate automatically.

Next comes the most important part: filtering the list. By default, the list will show all opportunities (that you have at least read access to). We can use up to 10 filters to limit the data that’s shown. Let’s start with our first parameter of Opportunities not in the Closed Won or Closed Lost stage. Click on the first field dropdown and select “Stage”; in the operator dropdown, select “not equal to”; in the value field, click the lookup icon and click the checkboxes for Closed Won and Closed Lost, and click the “Insert Selected” button. Next, we’ll use the second row to add the parameter for Opportunities that haven’t been modified in over 2 weeks. Select “Last Modified Date” in the field dropdown; select “less than” in the operator dropdown(*see read more for additional notes on date operators); type 14 DAYS AGO in the value field. The finished filter section should look something like this:

lv3

Next, we’ll need to select which fields we’d like to display in the related list. Let’s select the following from the available fields on the left (hold down Ctrl to select multiple fields) and click the add button to move them to the selected fields on the right: Opportunity Name, Account Name, Amount, Close Date, Stage, Owner Full Name, Last Modified Date, and Last Activity. Now, we can arrange the selected fields in the order we’d like using the Top, Up, Down, and Bottom buttons on the right. Let’s select Owner Full Name and move it just below the Opportunity Name so we can easily see who the owner is.

lv4

Lastly, if we have the Manage Public List Views system permission, we can choose whether we’d like this List View to be available to just the user who’s creating it, all users, or just certain groups (we’re able to share with public groups, roles, roles and internal subordinates, or roles and internal and portal subordinates). For this example, we’ll share with the Chief Sales Officer.

lv5

All we have to do now is click Save and we’ll have a Custom List View!

lv6

In the List View, we can click on any column header to sort alphanumerically ascending (click again to sort descending). We can easily follow records using the green plus sign, edit and delete. If we add an additional parameter to only display a single record type, we can also inline edit (if we have that feature enabled). How easy!

Wow… Test User sure has some outdated Opportunities out there! If we edit the List View and share with all users, we can direct Test User to the List View and show them how they can monitor this list and easily keep all their deals fresh and up-to-date. It’s all about that user experience!

Thanks for reading the second post in our List View series! Tune in next week for more!

Have another topic you’d like to see in the future? Send us a tweet! @BeardforceTyler

Read More »

Custom List View Series Part 1: The Basics & Filter Overview

salesforce-simplification-header

Do you need easy access to a subset of data? Are you tired of sorting through a vast amount of reports to find what you’re looking for? Spend your time more efficiently in Salesforce by creating your own list views!

In today’s post, we will go over how to create a list view that meets your filter criteria.

Note: We are using the Lightning Experience desktop user interface in this post. Look for a similar post for the Salesforce Classic interface in the near future! 

Overview

List views give you instant access to specific sets of data. Unlike reports, which may total in the thousands for your organization, list views are reserved for sets of data you find important and want easy access to often. Reports sometime have a “create it and forget it” purpose when you need a very specific set of data that you may never need again. List views are great for the sets of data you look at often and want front and center in Salesforce!

Accessing List Views

We’ll use the opportunity object as our example in this post. List views are available for any object in Salesforce that has a Tab.

List View blog post - 1

You can sort the records by one of the field columns in the list view. This sorting is done alphanumerically. Just click the header of the column you want to sort by. The first click will sort by ascending order. Click again to sort by descending order.

List View blog post - 5

Creating Custom List Views

Let’s create a custom list view for my best opportunities. These will be my opportunities in the Awaiting purchase order/LOI stage that are $50,000+ or any opportunities with the ABC Company account.

List View blog post - 2

List View blog post - 3

List View blog post - 4

List View blog post - 6

List View blog post - 7

List View blog post - 8

List View blog post - 9

List View blog post - 10

This list view now shows my opportunities in the Awaiting purchase order/LOI stage that are $50,000+ in addition to my opportunities from ABC Company.

List View blog post - 112

Because I already know these are my opportunities, I can remove the Opportunity Owner Alias field.

List View blog post - 113List View blog post - 114

List View blog post - 115

 

Thank you for reading my blog! Eager to learn more on this topic? Stay tuned for our multi-week series on list views!

If you have Salesforce tips or tricks you would like to see in this blog, tweet @JessSFDC and let me know.

Until next time,may-the-salesforce-be-with-you-footer

Deep Dive into the Day of the Week Formula

Formula fields: the duct tape of Salesforce… they can do nearly anything: fetch information across objects, perform complicated calculations, concatenate data (to name just a few). Specifically for dates, there are many great functions that can identify the day of the month, the month itself, and the year. What isn’t inherently available is the ability to use a simple function to identify the day of the week. Fortunately, Salesforce (and many Community members and bloggers) have assembled a formula that returns the day of the week.

Let’s take a closer look at the fomula provided by Salesforce. For the purposes of this explanation, we will use dateField as a place holder for a date field.

CASE(

MOD( dateField – DATE( 1900, 1, 7 ), 7 ),

0, “Sunday”,

1, “Monday”,

2, “Tuesday”,

3, “Wednesday”,

4, “Thursday”,

5, “Friday”,

“Saturday”

)

This formula utilizes two functions: CASE() and MOD().

  • CASE(expression, value1, result1, value2, result2,…, elseResult)

This function evaluates an expression (in our formula, the expression is MOD(dateField – DATE(1900, 1, 7), 7) ) and returns a result when the expression equals the corresponding value.

  • MOD(expression, divisor)

This function divides an expression by the divisor (in our formula, the expression dateField – DATE(1900, 1, 7) is being divided by 7) and returns the remainder (a la middle school division). E.g. MOD(12,3) would return 0, as 12 divided by 3 is 4; MOD(25,3) would return 1, because 25 divided by 3 is 8 remainder 1.

So what exactly is the formula doing? Why are we using January 7, 1900? The overall methodology is to find the number of days between any known Sunday in the past (we could use any Sunday after 1/1/1700; 1/7/1900 is simply the most commonly used Sunday) and the desired date to evaluate, divide that number by the number of days in a week, find the remainder and count that many days from Sunday. For example, today’s date (7/5/2017) is 42,913 from 1/7/1900. When we divide 42,913 by 7, we get 6130 remainder 3; 3 days from Sunday is Wednesday, which is the correct day! The CASE part of the formula is what returns the name of the day of the week; you can see above that the result that corresponds with the value 3 is “Wednesday”.

Variation: Next dayOfWeek

Let’s say your organization classifies all new contacts by the Saturday on or after which they were added. To show this easily, you want to create a formula to display the Saturday after the Created Date (provided that the Contact was not created on a Saturday). Let’s work backwards on this one.

Say the created date is today, July 5, 2017. We want to show Saturday, which is 3 days from today.

Wednesday + 3 = Saturday

(day 3) + 3 =  (day 6)

See where we’re headed yet? The variable in the formula will be the number of days to add to the Created Date to show a Saturday; we have already calculated the “day number” above using MOD(); Saturday will be hard-coded as (day) 6. Please note that you’ll need to use the DATEVALUE() function to convert CreatedDate from DateTime to Date.

MOD(DATEVALUE(CreatedDate) – DATE(1900,1,7),7) + x = 6

x = 6 – MOD(DATEVALUE(CreatedDate) – DATE(1900,1,7),7)

So we’ll add x to the Created Date to show the next Saturday: DATEVALUE(CreatedDate)+(6-MOD(DATEVALUE(CreatedDate)-DATE(1900,1,7),7). This works well for cases where the number value of the day of the week is greater than the desired day to show, such as when the record was created Wednesday and we want to show the next Saturday, but if we wanted to show the next Tuesday, we’d end up showing the previous Tuesday (our value for x would be negative). So we’ll add an IF statement to add a week when the desired day of the week has passed in that week: DATEVALUE(CreatedDate)+(6-MOD(DATEVALUE(CreatedDate)-DATE(1900,1,7),7)+IF(6-MOD(DATEVALUE(CreatedDate)-DATE(1900,1,7),7>=6,7,0).

In this case, there is no day in the week after Saturday, so we’re in the clear. But if we classified the contacts by the Sunday of the week they were added, it would be another story. There you have it! It may not be easy on the eyes, but hopefully we’ve helped you to navigate the formula and variation.

Use Case: Login Flow

One potential use case for the Day of the Week formula is the rendering of Login Flows. Our post last week addressed the creation of Login Flows to better guide your users to what they need. What if you need to change the user login experience depending on the day of the week? Now you can do so easily. Simply create a formula in the Flow that determines the “day number” and a decision block that checks that day of the week. If you want to create one path for weekend logins, make the parameters formula = 0 OR formula = 5 OR formula =6. Now you can send special reminders to complete timecards on Fridays, update open opportunities before close for the week, or anything else that can help your users have a better experience.


There are plenty of other great ways to utilize the Day of the Week formula. We hope this post has you thinking of use cases for your own org, and we appreciate you taking the time to read today. Have another topic you’d like to see in the future? Send us a tweet! @BeardforceTyler