Formula Fields: Displaying Today’s Date in Long Date Format

Salesforce Simplification header

Did you miss us? Our apologies for the long hiatus!

Now…let’s get down to business!

Everyone knows about Salesforce’s TODAY() function that dynamically displays today’s date in Short Date format (12/31/2000). But what if I want to see the Long Date format?

Create a Formula Field

Today formula

Result

Today formula result

  • Day of the week: This formula works by picking a known Saturday in time (January 6, 1900 for example), subtracting it from today’s date, and using MOD to divide the result by 7 – the remainder is returned as the day of the week.
  • Month: This formula works by displaying the month name based on the month number
  • Day: Because the formula return type is text, we need today’s day returned as a text value
  • Year: Because the formula return type is text, we need today’s year returned as a text value
  • Concatenating: We string everything together by concatenating the results in this formula. We use the ampersand (&) in between each formula and ” ” or “, ” to include a space or comma/space

Copy/paste this formula to use in your Salesforce org:

CASE(MOD( TODAY() – DATE(1900, 1, 6), 7), 0, “Saturday”, 1, “Sunday”, 2,”Monday”, 3, “Tuesday”, 4, “Wednesday”, 5, “Thursday”, 6,”Friday”,””) & “, ” &
CASE(MONTH(TODAY()),
1, “January”,
2, “February”,
3, “March”,
4, “April”,
5, “May”,
6, “June”,
7, “July”,
8, “August”,
9, “September”,
10, “October”,
11, “November”,
12, “December”,
“None”)
& ” ” & TEXT(DAY(TODAY())) & “, ” & TEXT(YEAR(TODAY()))

 

 

 

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

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 to, 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