コンテンツにスキップ

The Assigned-Rep Field

このコンテンツはまだ日本語訳がありません。

Module 5 of 6 in the chapter Object and Field Security: What Users Can Touch, chapter 4 of Securing Salesforce: Sharing and Visibility. Each module stands on its own.

The question this module answers: When a requirement can’t be met out of the box, how do you take it apart layer by layer, and build a solution that holds?

This module is different from the others in this chapter. It doesn’t teach one feature. It teaches what to do when a requirement can’t be met out of the box: how you take it apart layer by layer, and how you may end up with a hybrid, a solution built from several layers that each do one job.

Here’s the requirement. I’ve run into it at a client, and I still give it to every class.

The requirement. An account has a field called Special Access. It’s sensitive: think of it as truly HIPAA-level or PII data. The account also has an Assigned Rep, a lookup to a user. The business says: only the assigned rep sees Special Access. Every other rep can still see the account. They just can’t see that one field.

Try it yourself before you read on. Who can solve it for me? What are your choices?

Chapter 1, module 3 sketched the answer. This module works it through, one layer at a time. Each layer ends the same way: what it solves, where it leaks, and why you need the next one.

Most field requirements are a yes or no: does this kind of user have the field, or not? That’s field-level security, from module 2, and it’s straightforward.

This one isn’t a yes or no. It depends on the record. On one account, Maria is the assigned rep and should see the field; on the next account, she isn’t, and shouldn’t. Field-level security can’t do that, because it’s about the field on every record the user can see. And you can’t hide the whole account, because the reps who aren’t assigned still need it.

So the requirement is: the assigned rep needs the field, and the other reps still need record access.

The assigned-rep problem The assigned-rep problem. The assigned rep, named in the account's Assigned Rep field, should see the sensitive Special Access field and sees the rest of the account. Other reps can see the rest of the account, but not Special Access. Footnote: field-level security is about the field on every record; this rule depends on the record. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.53.0", "built": "2026-10-29", "id": "DGM-SVA-OF-13", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.4.0", "theme": "stevetecharc 1.4.0"} THE USERS THE ACCOUNT The assigned rep named in Assigned Rep Other reps can see the account Special Access a sensitive field The rest of the account name, contacts, activity should see sees sees Field-level security is about the field on every record. This rule depends on the record. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Layer 1, out of the box: field-level security

Section titled “Layer 1, out of the box: field-level security”

Start with what Salesforce gives you, the base level control from module 2: give the field only to the permission sets that need it, Read for those who view it, Read and Edit for those who change it. If the rule were “account managers see Special Access, reps don’t,” you’d be done.

But the rule here is “the assigned rep on this account.” Every rep might be the assigned rep on some account. So every rep would need the field, and then every rep sees it on every account.

What it solves: who has the field at all. Where it leaks: it can’t tell one account from the next. So it’s necessary, but not enough. Keep it, and add a layer.

Layer 2, on the page: conditional visibility

Section titled “Layer 2, on the page: conditional visibility”

The answer I usually get first is a visibility filter, and it’s a good answer. In Dynamic Forms, show Special Access only when the current user is the assigned rep. That works on the page.

But here’s the problem, from modules 3 and 4. To show the field at all, you have to give users field-level access to it, even the ones the filter hides it from. Once they have field access, they can come along, take a list view and add that field. You can’t stop them. It’s in reports, in dashboards, in global search. You can keep it off the screen, but you can’t keep it out of the other ways in.

So conditional visibility is fine for convenience, knowing that it still shows up in list views, reports and search.

What it solves: the page. Where it leaks: everywhere else. It’s not the answer for a field that truly has to be secured. Out of the box has run out, so the next layer is one you build.

Layer 3, in code: lock it down, and show it on purpose

Section titled “Layer 3, in code: lock it down, and show it on purpose”

If the field truly needs to stay on the account and be locked down, there’s one way I know to do it. Don’t grant the field-level security at all. Nobody but the admins has the field. Then build a small Lightning web component (LWC) for the account page. The LWC is the screen; the reading happens in Apex. The LWC calls a method in an Apex class: “Lightning web components can import methods from Apex classes,” and call them (Call Apex Methods (opens in a new tab), Lightning Web Components Developer Guide, checked 2026-11-01). That Apex reads Special Access on the user’s behalf, checks whether the current user is the assigned rep, and only then returns the value for the LWC to show.

Because no rep has the field, it isn’t in list views. It isn’t in reports or dashboards. It isn’t in search. It only appears in that LWC, for that one person, on that record.

Two things make this work, and both are deliberate.

  • The Apex has to ask for system mode, on purpose. Since Summer ‘26, Apex database operations in code saved at API version 67.0 or later run in user mode by default: they “enforce the sharing rules, field-level security, and object permissions of the current user.” A query for a field the rep can’t see now fails to read it unless the code says otherwise, with WITH SYSTEM_MODE on the query or AccessLevel.SYSTEM_MODE on a Database method. Salesforce’s own words for why: “Database operations bypass object- and field-level security settings only if you explicitly set them to run in system mode. This requirement promotes intentionality” (Summer ‘26 release notes: Database Operations Run in User Mode by Default, Not System Mode (opens in a new tab), checked 2026-11-01). That’s good for this pattern: the one exception is written in the code where a reviewer can see it.
  • The check belongs in the Apex, not the page. The Apex decides who sees the value, not the LWC and not the page. If the check is wrong, the value leaks, so test it as an assigned rep, as an unassigned rep, and as a user with no access to the account.
Three layers for one sensitive field Three layers for one sensitive field. Layer 1, grant it narrowly, with field-level security: only the permission sets that need it, but every possible assigned rep would see it everywhere. Layer 2, conditional visibility, a Dynamic Forms filter: hidden on the page, but still in list views, reports and search. Layer 3, locked down, an LWC on purpose: no field-level security except admins; its Apex reads it in system mode and shows it only to the assigned rep. Footnote: since Summer '26, system mode has to be asked for in the Apex. {"author": "Steve Simpson", "blueprint": "2.0.0", "builder": "standard 1.53.0", "built": "2026-10-30", "id": "DGM-SVA-OF-14", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison 0.5.0", "theme": "stevetecharc 1.4.0"} Layer 1: grant it narrowly field-level security Only the permission sets that need it Every possible assigned rep sees it everywhere Layer 2: conditional visibility a Dynamic Forms filter Hidden on the page Still in list views, reports and search Layer 3: locked down an LWC, on purpose No field-level security, except admins Its Apex reads it in system mode Shown only to the assigned rep Since Summer '26, system mode has to be asked for in the Apex. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Test knowledge. Know the assigned-rep pattern: one sensitive field, visible only to one user, on a record other users can see. Field-level security alone can’t do it, and a visibility filter leaks through list views, reports and search. The locked-down answer is no field-level security, and an LWC whose Apex reads the field in system mode on purpose and checks the user. Know the modeling alternative too: a lookup child with a Private default owned by the assigned rep works; a master-detail child, Controlled by Parent, doesn’t. It’s a pattern architects meet again and again, in real orgs and on the architect journey. A likely area, not a known question.

Here’s the catch with Layer 3. A display LWC like this works great. Editing is harder. In my experience, a custom LWC doesn’t drop into the standard new and edit screens, so the rep can’t change Special Access in the normal edit window.

So you build editing too. The usual answer is to put the whole field in its own small edit LWC off to the side of the page: private fields, blank for everyone else, and for the assigned rep, the value and an edit button. Its Apex saves the change, in system mode on purpose, and only after checking the user again.

It’s more work, and that’s the point. The protection sits in the security layer, where it can be reviewed and tested, not on the page layout, where it can be bypassed.

In class I’ve said I wish Salesforce gave us a way to elevate a Dynamic Forms field, to say “show this field to this person on this record, without granting the field.” It doesn’t. So the LWC, and its Apex, is the tool.

Display is easy; edit is the work Display is easy; edit is the work. The assigned rep opens the account: a display LWC shows the value; its Apex checks the user and reads Special Access in system mode. The assigned rep changes the value in an edit LWC; its Apex checks the user again and saves in system mode. Special Access has no field-level security for reps. Footnote: every other rep sees a blank space; the protection sits in the Apex, where it can be reviewed and tested. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.53.0", "built": "2026-10-29", "id": "DGM-SVA-OF-15", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.4.0", "theme": "stevetecharc 1.4.0"} THE USER ON THE ACCOUNT PAGE THE FIELD The assigned rep Display LWC its Apex checks the user Edit LWC its Apex checks again, then saves Special Access no field-level security for reps opens changes Apex reads in system mode Apex saves in system mode Every other rep sees a blank space. The protection sits in the Apex, where it can be reviewed and tested. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Layer 3, another way, in the data model: a record of its own

Section titled “Layer 3, another way, in the data model: a record of its own”

There’s another way to build the third layer, and it’s a modeling answer, not a code answer. Take Special Access off the account and put it on a record of its own, a child of the account. Then protect that record with sharing, not field-level security. Whether it works depends on one decision: the kind of relationship.

A master-detail child doesn’t help. A detail record’s org-wide default is Controlled by Parent: “Users can perform actions (such as view, edit, delete) on a record on the detail side of a master-detail relationship if they can perform the same action on all associated master records” (Set Your Internal Organization-Wide Sharing Defaults (opens in a new tab), Salesforce Help, checked 2026-11-01). Every rep who can see the account can see its Special Access record. You’re back where you started.

A lookup child, with its own sharing, can. Give the child object its own org-wide default of Private: “Only users who are granted access by ownership, permissions, role hierarchy, manual sharing, or sharing rules can access the records” (same page). Make the assigned rep the owner of the account’s Special Access record. Now only the assigned rep can see it, and because it’s protected by sharing, it doesn’t show up for anyone else in list views, reports or search. There’s no LWC or Apex to build for display or edit: the assigned rep just opens the record.

Two catches.

  • The role hierarchy. Under a Private default, the owner’s managers above them in the role hierarchy can see the record too. For a custom object, you can turn Grant Access Using Hierarchies off; for standard objects, Salesforce says it “can’t be modified” (Controlling Access Using the Role Hierarchy (opens in a new tab), checked 2026-11-01, chapter 1). Decide whether managers should see it, and set it on purpose.
  • Keeping it in step. When the account’s assigned rep changes, the child record’s owner has to change with it. That’s automation you build and test.

So the choice is code or modeling. The LWC keeps the field on the account and puts the rule in Apex. The child record moves the field to its own object and puts the rule in sharing. Both work, if they’re built right. Part 2 of the course covers the mechanics: org-wide defaults, the role hierarchy, and how relationships share.

A record of its own: master-detail or lookup Three columns. A master-detail child, Controlled by Parent: anyone who can see the account can see the record, so every rep sees Special Access; it doesn't solve it. A lookup child, with its own Private default: the assigned rep owns the record, only the assigned rep sees it, and it isn't in others' list views, reports or search. Two catches for the lookup child: the owner's managers can see it unless the hierarchy is turned off, and the owner must change when the rep changes. Footnote: code or modeling; the LWC puts the rule in Apex, a record of its own puts it in sharing. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.53.0", "built": "2026-10-30", "id": "DGM-SVA-OF-16", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "comparison 0.5.0", "theme": "stevetecharc 1.4.0"} A master-detail child Controlled by Parent Can see the account: can see the record Every rep sees Special Access Doesn't solve it A lookup child its own Private default The assigned rep owns the record Only the assigned rep sees it Not in others' list views, reports or search Two catches for the lookup child The owner's managers can see it Unless the hierarchy is turned off Change the owner when the rep changes Code or modeling: the LWC puts the rule in Apex; a record of its own puts it in sharing. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

Look at what actually solves the requirement. It isn’t one feature. It’s layers, each doing one job.

  • In code: field-level security takes Special Access away from every rep (Layer 1, used to take away rather than grant). A display LWC and an edit LWC put it on the account page for the assigned rep. Their Apex reads and saves in system mode on purpose, and checks the user every time (Layer 3). Tests cover the assigned rep, an unassigned rep, and a user with no access to the account.
  • In the data model: field-level security still decides who can have the field at all. A lookup child with a Private default holds it, the assigned rep owns the record, Grant Access Using Hierarchies is set on purpose, and automation keeps the owner in step with the account.

Layer 2 isn’t in either answer. It’s still useful for convenience on the page, but it was never going to hold the secret.

Layer by layer, to a hybrid Layer by layer, to a hybrid. Each layer is tried in turn. Layer 1, field-level security: necessary, not enough. Layer 2, the page: it leaks to list views, reports and search, so it is convenience only and is not kept. Layer 3, an LWC and its Apex, shows the field on purpose; or Layer 3 as a record of its own, a lookup child with a Private default. The answer is a hybrid: Layer 1 is kept, and one Layer 3 is added. Footnote: write down why each layer is there, so no one takes one away. {"author": "Steve Simpson", "blueprint": "1.0.0", "builder": "standard 1.53.0", "built": "2026-10-30", "id": "DGM-SVA-OF-17", "rights": "\u00a9 2026 Twinshark LLC. All rights reserved.", "template": "cells 0.4.0", "theme": "stevetecharc 1.4.0"} EACH LAYER, TRIED IN TURN WHAT THE ANSWER KEEPS Layer 1: field-level security necessary, not enough Layer 2: the page leaks: convenience only Layer 3: an LWC and its Apex shows it on purpose Or Layer 3: a record of its own a lookup child, Private The hybrid Layer 1 plus Layer 3 kept added or added Write down why each layer is there, so no one takes one away. © 2026 Twinshark LLC · stevetecharc.com
Click to enlarge

This is how I take apart any requirement that out of the box can’t meet, in sharing or anywhere else.

  1. State the requirement in the business’s words, and the constraint that makes it hard. Here: one person sees the field, and everyone else still sees the record.
  2. Try out of the box first. Field-level security, sharing, the page. Most requirements stop here.
  3. Find where it leaks. List views, reports, search, the API, files, managers in the role hierarchy.
  4. Add the next layer, and only that layer: the page, then code or the data model.
  5. Stop when it holds, and test it as every kind of user.
  6. Write down why each layer is there, so the next person doesn’t take one away.
  • “Some kinds of users, never others”: Layer 1. Field-level security, nothing else.
  • “Show it here, now, for convenience”: Layer 2, on top of Layer 1.
  • “Only this person, on this record, and it truly must be secret”: a hybrid. Layer 1 takes the field away, and Layer 3 shows it on purpose: an LWC whose Apex runs in system mode on purpose, display and edit both built and tested.
  • Or, for the same rule, Layer 3 in the data model: a lookup child with a Private default and the assigned rep as owner. Never a master-detail child.
  • Whether a requirement can be met out of the box, and if not, which layer is added next and why.
  • Whether a sensitive field’s rule is a yes or no by user, or depends on the record.
  • For a record-dependent rule, whether the field truly must be secret, or convenience is enough.
  • Who reviews code that runs in system mode, and that every such query is there on purpose.
  • How the assigned rep edits the value, and how that’s tested.
  • Whether the rule lives in code (an LWC and its Apex) or in sharing (a record of its own), and, for a record of its own, its relationship, its default, its owner and the role hierarchy setting.
  • How the test plan covers the assigned rep, an unassigned rep, and a user with no access to the record.

Beyond the exam: what AI changes. A locked-down field is only as locked as every piece of code that reads it in system mode. If an agent action reuses that LWC’s Apex, the agent can read the field for anyone who asks it, unless the action checks the user the same way. When you add system-mode code, add a note for every future caller: who is allowed to see what this returns. Chapter 20 covers agents.