Featured image of post Dynamically Showing Accounts in Salesforce Based on the Logged-In User

Dynamically Showing Accounts in Salesforce Based on the Logged-In User

Managing account visibility in Salesforce can be tricky when pulling data from an external ERP like Dynamics AX. This post explores how we dynamically filter accounts so users only see what’s relevant to them—without manual assignments!

Dynamically Showing Accounts Owned by the Logged-In User

With a recent Salesforce implementation well underway at work, one of the issues highlighted early on was the need to show only the accounts assigned to each user.

Since this setup was pulling data from an ERP (Dynamics AX) on a 24-hour cycle, the usual method of assigning accounts in Salesforce wasn’t going to work. Typically, in Salesforce, the employee responsible for an account is the one who creates it. However, with data syncing from an external system, we needed another approach.

🧐 Finding a Solution

After some Google-fu to see what solutions others had implemented, we settled on the following approach:

  1. Each User Account in Salesforce had their ERP “Name” set as their Salesforce Nickname.
  2. A new custom field was created on the Account object with logic to flag whether the logged-in user was responsible for the account.

🔧 Implementing the Logic

The following formula was used in the custom field:

1
2
Is Employee Responsible? = 
IF( $User.CommunityNickname = Employee_Responsible__c, TRUE, FALSE )

This custom field wasn’t added to any standard views—it exists in the background, purely for filtering purposes.

📋 Setting Up the “My Accounts” View

In the My Accounts table list view, the filter was configured as:

  • Show All Accounts
  • Is Employee Responsible? = TRUE

🎯 How It Works in Practice

Let’s say a user, Joe Bloggs, logs into Salesforce. His Salesforce Nickname is set to J Bloggs. When he navigates to the Accounts List View and selects My Accounts, Salesforce will:

  • Compare Joe’s Salesforce Nickname (J Bloggs) with the Employee Responsible field in each account (pulled from the ERP system).
  • Display only accounts where the values match.

The Result?

Only the accounts that Joe Bloggs is responsible for appear in his view—ensuring clean, relevant data without manual assignment headaches.

Pretty neat, huh? 🚀