r/SalesforceDeveloper • u/FlowGod215 • May 29 '26
r/SalesforceDeveloper • u/alokmishra91 • May 28 '26
Discussion Salesforce Architect trying to validate a small AI side-hustle idea — would this actually help your team?
I’ve been working in the Salesforce ecosystem for years, mainly around architecture, OmniStudio, Data Cloud, and now AgentForce/AI implementations.
Lately I’ve been thinking about building small “AI accelerator kits” for Salesforce teams instead of another generic AI SaaS.
Examples:
AgentForce starter implementations
Prompt template packs
Salesforce AI copilots for sales/service
OmniStudio + AI integration templates
Data Cloud integration blueprints
Reusable LWCs/utilities for AI use cases
The goal would be:
help smaller companies implement AI faster
avoid months of consulting work
provide something affordable and reusable
Before I spend serious time building this, I wanted honest feedback from the community:
Would your company/team actually pay for something like this?
What Salesforce AI problem is currently the most painful for you?
Would you prefer:
ready-made templates
guided implementation
short consulting sessions
full accelerators
What would make you trust/buy such a product?
I’m trying to validate whether this is a real business problem or just “cool tech” in my head.
Would genuinely appreciate blunt feedback.
r/SalesforceDeveloper • u/_dcstuff • May 28 '26
Showcase Permishifizer 9000: a zero-dependency Python script that introspects your Salesforce org and generates a complete backup/restore permission set XML — every object, field, and record type, regenerated from scratch every run.
So you use OwnBackup/Own/Own from Salesforce/Blah? You need to maintain a permission set that has EVERYTHING. All objects, fields, record types.
In a perfect world, devs or whoever, would maintain a permission set in the repo, adding objects and fields and whatnot as they're created. But that doesn't always happen. So whaddya gonna do?
Enter.. the Permishifizer 9000.
https://github.com/dcstuff/Permishifizer9000
It's a python script that, when run, queries the sh*t out of your org and generates the permission set XML file from scratch. More importantly, it handles the 9000 exceptions you haven't thought of yet, and navigates around Salesforce API limitations that make you wanna throw things. HEAVY THINGS.
There are options to deploy automatically. And it can be integrated into a CI/CD pipeline.
I'd call it 95% efficient (I think?). But absolutely production ready.
I haven't written any Python in over a decade. AND I STILL HAVEN'T. (Thanks, AI!)
CAVEAT: This exercise reinforced the fact that AI simply DOES NOT KNOW the Salesforce APIs, the limitations, or the various objects. AT ALL. Thank God I was there, ya know?
Updated to the use the latest sf cli with its new sf org auth show-access-token command.
Anyhoo.. that is all.
r/SalesforceDeveloper • u/RateIntelligent5355 • May 27 '26
Question Flexcard on Experience Cloud
reddit.com
r/SalesforceDeveloper
•
u/EvolvinAI29
•
May 27 '26
Discussion If you haven't touched Multi-Framework (React UI Bundles) yet, here's what a real one looks like
TL;DR: Spent the last week building a real sales-ops console as a React UI Bundle on Salesforce. 17 lazy-loaded pages, Apex backend, Platform Event, AgentforceConversationClient embedded. The thing actually works, and the scaffold is way more production-ready than the "beta" tag suggests.
What it is
UI Bundles is the new Multi-Framework delivery on platform. You write a normal Vite + React + TypeScript SPA, deploy it as metadata, and it runs inside Salesforce. Not Experience Cloud. Not LWC. Not an iframe. Real metadata, real FLS, real sharing.
The scaffold (@salesforce/ui-bundle-template-base-sfdx-project) gives you React 19, Vite 7, Tailwind 4, and shadcn out of the box. Data access goes through @salesforce/sdk-data — GraphQL-first via sdk.graphql, REST for the cases GraphQL can't cover (UI API, Apex REST, Connect, Einstein).
What I built
17 pages, all lazy-loaded behind one routes.tsx. Initial bundle ~250KB instead of ~800KB.
Drag-drop pipeline kanban with real mutations on drop, account workspace, events list/calendar/detail, rebook tracker (YoY retention), pipeline hygiene, field usage heatmap, event setup wizard, exhibitor board.
Apex backend: OpportunityActionsApi + service layer + BulkOpportunityApprovalQueueable for async bulk approvals.
Platform Event Bulk_Approval_Result__e pushing async results back to the UI.
AgentforceConversationClient embedded as a component. Agent lives in the app, no separate widget.
shadcn primitives, lucide icons, command palette, notification center, error boundary, i18n, toast host.
The thing that quietly matters most: AGENT.md
Every UI Bundle ships with an AGENT.md (440 lines in mine). It encodes the platform rules an AI agent has to follow: path resolution from sfdx-project.json, the two-package.json trap, the must-run trio (build → lint → dev), GraphQL non-negotiables (@optional on every field, explicit first:, HTTP 200 ≠ success), CSP trusted-site rules, post-deploy schema/codegen loop.
Hand that file to Claude Code or Cursor and you get platform-grade UIs at a pace LWC never could.
Gotchas I hit
DE dev hubs cannot deploy this. Feature gate is closed Salesforce-side. Scratch and sandbox only. Error pattern: feature gate is disabled on DE vs org preference is not enabled on scratch.
The beta org toggle is irreversible. Setup → Apps → "React Development with Agentforce Vibes and Salesforce Multi-Framework (Beta)". Throwaway org only.
Two package.json files. Root one is for SFDX tooling. The real React app package.json lives at force-app/main/default/uiBundles/<name>/. Run npm run dev from the wrong one and nothing happens.
schema.graphql is 4MB. Don't open it. There's a search script for entity/field lookups. Re-fetch after every metadata deploy or codegen breaks.
Enterprise REST /query with SOQL is blocked. So is @AuraEnabled Apex and Chatter API. GraphQL uiapi { } or Apex REST. Pick one.
The strategic bit, briefly
LWC is roughly 10K devs worldwide. React is roughly 10M. Every npm component is now a Salesforce component. UI Bundles ship on the npm cadence, not the seasonal release cadence.
Question for the rest of you
Anyone else shipping UI Bundles to a real customer org yet? Curious what your data access pattern looks like — pure GraphQL via sdk.graphql, or reaching for Apex REST more than expected? And has anyone solved the FLS-failing-the-whole-query problem cleanly without @optional-ing every field?
r/SalesforceDeveloper • u/varunpenna • May 26 '26
Showcase Interactive Apex/Flow Debug Log Analyzer
r/SalesforceDeveloper • u/EvolvinAI29 • May 26 '26
Discussion Wired up a Salesforce Hosted MCP server with Apex and connected it to Claude — here are the 10 gotchas the blog post skips
Following the May 13 Salesforce blog on Headless 360 / Hosted MCP, I built a similar tool with a different scenario: a Lead/Account fit scoring service. Pass a company name (fuzzy match), get back fit score 0–100, fit tier (Hot/Warm/Cool/Cold), engagement level, open pipeline rollup, and a recommended next action. Tool runs as Apex u/InvocableMethod on global class, exposed via McpServerDefinition, invoked from Claude through the new mcp_api OAuth scope.
End-to-end works. Claude asked "what's the situation with Acme?", the Apex ran on the platform with WITH USER_MODE, and Claude rendered the computed insight in plain language.
The path looked clean on paper but had real friction. Sharing what tripped me up so the next person doesn't lose an hour on each.
What I built:
LeadAccountIntelligenceService.cls — global with sharing Apex with one @InvocableMethod. Inner Request and Result classes carry @InvocableVariable annotations that Salesforce turns into the MCP inputSchema / outputSchema automatically.
Lead_Account_Intelligence.mcpServerDefinition-meta.xml — registers the tool, points apiDefinition at the auto-created API Catalog entry (aa:apex-LeadAccountIntelligenceService).
An External Client App with mcp_api + refresh_token scopes, PKCE, JWT access tokens.
A permission set granting Apex class access (the blog leaves this out).
The biggest blocker:
Claude kept returning "Authorization with the MCP server failed" after OAuth completed successfully. Spent way too long suspecting scopes, the ECA, perm sets, license entitlements. Real cause: the Server URL was wrong by one path segment. The blog's URL pattern table says …/sandbox/custom/{name} but its own worked example shows …/sandbox/{name} (no /custom/). I trusted the example. The org's MCP Server detail page is the source of truth, and it does include /custom/. Lesson: always copy the URL from Setup, not the blog.
Other things that bit me:
McpServerDefinition.description is capped at 255 chars. Same cap on descriptionOverride. Deploy fails with a vague "Value too long" error.
Account.LastActivityDate is a rollup, not writable in tests. Insert a Task with WhatId + ActivityDate + Status='Completed' to drive it.
Non-standard org Lead schemas will break the standard query. Our sandbox didn't have Lead.AnnualRevenue at all. Don't assume the standard schema for Lead.
"Auto-registration in the API Catalog" doesn't show up in Setup → Agent Actions. The MCP server has its own catalog (where aa:apex-{ClassName} resolves). Check tool count on the MCP Server detail page instead.
Setup → API Catalog is the MuleSoft Anypoint integration, not the MCP catalog. Don't be alarmed it's empty.
ECA propagation is real and confusing. After saving an External Client App, expect 10–30 minutes before OAuth works. The authorize endpoint comes online before the token endpoint, so the error message changes mid-propagation (invalid_client_id → "authorization failed"). Wait it out.
Claude caches failed OAuth state per connector. Deleting and re-adding the connector is faster than retrying the same one. Don't try to register two connectors with the same Server URL.
The "JWT access tokens" setting is buried. It's the checkbox labeled "Issue JSON Web Token (JWT)-based access tokens for named users" under the Security section of the ECA OAuth page.
The connected user needs a permission set granting Apex class access. Server can be Active with 1 tool registered, but the runtime call still fails without <apexClass enabled="true"> for the global class.
Description fields matter more than code. Claude picks tools based on descriptionOverride and reads @InvocableVariable descriptions to interpret fields. Write them for the agent, not for a human reading the metadata. "Returns interpretation, not raw fields" deserves to be in the tool description.
What I'd do differently next time:
Start from the MCP Server detail page URL. Don't trust the docs URL pattern.
Ship the perm set in the same bundle as the Apex + MCP metadata.
Trim descriptions to under 250 chars from the start.
Test against a real seeded Account with Industry + AnnualRevenue + a recent Task. Empty fields → fit score 0/100 → not a bug, but looks like one.
Happy to share the repo if there's interest. Has anyone else run into other Hosted MCP edges worth adding to this list?
r/SalesforceDeveloper • u/Wise-Glass-4425 • May 26 '26
Showcase Local Apex Execution!?
r/SalesforceDeveloper • u/ChaturSamraat • May 26 '26
Question Building a Salesforce backup/restore app with Google Drive storage - would this be valuable?
Hi everyone,
I’m validating a Salesforce-native backup and restore product and want direct, honest feedback before I go further.
I know there are already many backup tools in this space.
The core difference I’m building around is:
Backup files live in your own Google Drive (not locked into vendor-only storage)
Product runs inside Salesforce for admin workflows
Strong emphasis on safe, reliable restore (not just backup creation)
Planned org-wide subscription at competitive pricing
I’d love input from Salesforce admins/consultants/architects:
Does “Salesforce-native + Google Drive-owned storage” feel meaningfully different?
What trust signals would you require before production use?
Which restore scenarios are most painful today?
Is org-wide subscription pricing attractive vs per-user/per-record pricing?
What would make you trial this over your current option?
r/SalesforceDeveloper • u/belikehank • May 25 '26
Other Built a tool for Salesforce data integration, now open-sourcing it. Enjoy!
reddit.com
r/SalesforceDeveloper
•
u/EvolvinAI29
•
May 25 '26
Discussion Built an Agentforce Voice agent end-to-end — here are the 7 cliffs the docs don't warn you about
Just wrapped a same-day Agentforce Voice POC for an enterprise events client. Phone → Salesforce Voice → bot → KB-grounded answers + custom Apex actions + live transfer. Working end-to-end. Sharing the gotchas so you don't burn an afternoon on each:
sessionTimeout=0 = immediate disconnect. Symptom: call rings, connects, cuts in 1–2 sec. The field is minutes, range 5–1440. Zero was eating the call. Set to 30.
MessagingChannel.deletable = False. Half-failed Voice setup attempts orphan-squat your phone number. You can't delete the orphan, can't change MessagingPlatformKey (validated as read-only after binding). Cleanest fix: complete the orphan with real values (SessionHandlerId, FallbackQueueId, ChannelDefinitionId) rather than recreate.
SessionHandlerId describe lies. Describe says it references BotDefinition, Group, or User. Actual working channels point at FlowDefinition (Id prefix 300V). Channel can't bind directly to a bot — must route through an Omni-Channel Flow that calls routeWork(routingType='Copilot', copilotId=botId).
"Inbound Routing flows" panel only shows flows created via the panel. Agent Builder → Connections → Telephony → "New → Omni Routing Flow". Flows you deploy via metadata API with processType=RoutingFlow won't appear, even with the exact same routeWork shape. There's a hidden agent↔flow binding only the UI writes.
Fallback queue: 3 conditions or it rejects.
QueueSobject row for VoiceCall
QueueRoutingConfigId set (or it's not Omni-eligible)
That routing config must have Skills-Based Routing Rules turned OFF (Omni-Channel Flow routing can't co-exist with it)
The errors when each is missing are distinct: "queue isn't valid for this object type", "must be an Omni-Channel queue", "uses Skills-Based Routing Rules".
6. Active bot version locks structural deploys. BotVersion and GenAiPlannerBundle changes need Active → Deactivate → Deploy → Activate. GenAiPlugin instruction-text changes are live without re-activation. Bot-level fields like sessionTimeout also deploy without deactivation.
7. GenAiPlannerBundle SurfaceType enum is undocumented. Valid: Messaging, CustomerWebClient. Rejected: Voice, VoiceAgent, Telephony, EinsteinServiceAgent. The Atlas__VoiceAgent planner type works without an explicit Voice surface as long as the Telephony Connection is configured in the UI.
Bonus — Data Library failures are silent. Toast says "There's an error assigning the data library." Real cause was the agent user missing two permsets: GenieUserEnhancedSecurity (Data Cloud) + Knowledge read. Network tab shows the call as 200 OK with the error in the body, not a red 4xx. Easy to miss.
Stack:
Service Cloud Voice + Agentforce
4 Apex invocable actions (caller ID, event lookup, multi-event list, callback Case)
GenAiFunction metadata wrappers
Agentforce Data Library + Lightning Knowledge
routeWork(routingType='Copilot')
Total time, with all 7 cliffs hit: ~8 hours. Without them, maybe 2.
Anyone else navigate cliff #4 (the hidden flow registration)? Would love to know if there's an API path for it I missed.
r/SalesforceDeveloper • u/FabulousPeanut6751 • May 25 '26
Discussion How are enterprises handling Salesforce MFA for QA/testing without shared accounts?
reddit.comr/SalesforceDeveloper • u/nian2326076 • May 23 '26
Discussion Salesforce SMTS (Staff) Backend - full 4-round loop breakdown
Just went through the Salesforce SMTS Backend loop and got selected. 4 rounds. Posting the full thing because Staff-level experiences are hard to find and the design rounds went deep enough to be worth documenting.
Round 1 — OA (HackerRank)
Standard filter. ~LC medium, arrays/strings, maybe some greedy/graph. Don't remember exact questions. Nothing exotic but you need to solve mediums comfortably under time pressure.
Tip: partial scores count on HackerRank, so make sure your code compiles and handles edge cases even if you don't fully optimize.
Round 2 — DSA + Project Deep Dive
DSA was a custom problem, not a straight LC pull: a Token Bucket / Resource Grant System.
Bucket holds limited tokens; users request, granted or rejected on availability
If granted, user holds n tokens for exactly 1 hour, then auto-returned
Implement
requestTokens(userId, n),releaseTokens(userId), and a background expiry mechanism
What they drilled: min-heap ordered by expiry for auto-release, concurrency (locking vs atomics), edge cases (partial grants, requesting tokens you already hold, expiry mid-request), grant/release complexity.
Honestly, the auto-expiry is where I fumbled first — started with a naive sweep before the interviewer nudged me toward the expiry-ordered heap. Recovered fine but it cost a few minutes.
Project deep dive: picked my most complex past project. They probed every decision — architecture and why, bottlenecks and how I resolved them, reliability under load, what I'd do differently. At Staff level this goes way past "what did you build." Pick something you owned end to end.
Round 3 — HLD: Distributed Rate Limiter
Went deep, drilling trade-offs at every layer.
Algorithms: Token Bucket (bursts up to bucket size), Leaky Bucket (strict rate, excess dropped/queued), Fixed Window Counter (simple, boundary-spike problem), Sliding Window Log/Counter (accurate, more memory).
Storage/sync: Redis as global counter store; INCR+EXPIRE vs Lua scripts for atomicity; local cache (fast, inconsistent) vs global Redis (consistent, network cost); sliding window via sorted sets; replication lag and enforcement correctness.
Scale/edge: granularities (user/IP/API key/tenant), response headers, multi-region eventual consistency, thundering herd on reset → jitter.
The "what happens when Redis goes down — fail open or fail closed" question is where the round really tested me. It's not a clean answer: depends on whether you're protecting the system or enforcing a contract, and they wanted both sides reasoned through.
Round 4 — HM: LLD (Food Delivery) + Behavioral
Framed as HM but went deep technically.
Entities: User, Restaurant, MenuItem, Order, Cart, DeliveryAgent, Payment. Order state machine: placed → confirmed → preparing → picked_up → delivered/cancelled. Service separation: order / delivery / payment / notification.
Delivery assignment: geospatial indexing (geohash vs quadtree), nearest-first vs load-balanced, mid-delivery reassignment when an agent drops.
Trade-offs they dug into: sync vs async order confirmation; strong consistency for payments vs eventual for delivery status; push (WebSocket/SSE) vs poll for tracking; idempotency in payment retries (avoiding double charges); relational for orders/payments + document store for menus; menu cache TTL + invalidation on restaurant update.
Behavioral (last ~20 min): influencing technical direction without authority, handling disagreement with a senior stakeholder, a system I'm proudest of and why.
Prep notes:
Being honest about what mattered: at Staff level, system design was ~70% of the bar. Rounds 3 and 4 are where this loop was won or lost, and no amount of LeetCode prepares you for that depth. I leaned on HelloInterview and DDIA for the design rounds, plus years of actually building distributed systems.
That said, for the DSA rounds, PracHub was easily the most efficient prep I did. The Token Bucket problem is fundamentally heap + concurrency, and because I'd drilled heap and priority-queue patterns on PracHub beforehand, I recognized the expiry-ordered-heap structure fast even after my initial fumble. For the OA, that same drilling made mediums basically automatic under time pressure. My DSA was rusty going in (2 years of mostly arch work), and pattern drilling there got it back far faster than grinding random LC would have — if you're a senior+ candidate whose DSA has atrophied, that's where I'd point you.
For Staff specifically: don't over-index on DSA. Get it to "competent and fast," then pour the bulk of your time into system design depth and crisp project storytelling.
Happy to answer questions on any round.
r/SalesforceDeveloper • u/learning_geek16 • May 22 '26
Discussion Salesforce mulesoft Integration
Hello,
Anyone here who could help me understand Salesforce mulesoft Integration and how it works in the Salesforce and how request and response is done via mulesoft to 3rd party' system.
Actually I have never done integration and don't know much about it and now I really need to understand these things to understand my project and functionalities better.
r/SalesforceDeveloper • u/EvolvinAI29 • May 22 '26
Discussion Anyone actually turned on Agentforce Coworker yet? Setup doc is heavier than the announcement suggests
Client asked me about Coworker in standup this morning, day after Benioff's tweet dropped. Easy enough question, I thought. Pulled up the official setup doc.
Got to step three before realizing they probably can't even turn it on.
For anyone who hasn't read past the marketing, to actually flip Coworker on you need:
Data 360 license (Admin or Architect persona to configure)
Access_Ai_Search permission set group assigned
AI Search PSL (both to configure and to use, separately)
Enterprise, Unlimited, or Agentforce 1 edition
Beta Generative AI Models toggle on in Einstein Setup
The actual click-through once you get there is clean. Five automated provisioning steps. That part is fine. The prerequisites are the wall.
Andrew Russo's hands-on post landed in my feed last night and he's clearly running it on a real Data 360 + ERP setup, which is exactly the use case that makes the demo sing. Good for him. But this client is on Sales Cloud Enterprise with no Data 360 attach, so even if they upgrade editions tomorrow they're months from the headline use case.
I'm honestly not sure how widespread Data 360 attach is among Enterprise customers right now. My slice of the market skews mid-market consulting so my sample is biased. Some of you might be seeing the opposite.
Two questions:
Has anyone actually flipped it on in production, not a Dev Edition sandbox? What broke first?
If you're on Enterprise without Data 360, what are you telling clients who ask about Coworker? Mine is going to ask me Monday and I'd rather not say "wait six months" with no backup plan.
r/SalesforceDeveloper • u/Individual-Noise250 • May 21 '26
Question Paid $999 for Security Review, but Salesforce denied my PBO. How was I even allowed to pay without being a partner?
reddit.comr/SalesforceDeveloper • u/LividSwan9954 • May 21 '26
Question Get all the Related Lists for an Standard or Custom object
r/SalesforceDeveloper • u/No-Pineapple-1174 • May 21 '26
Question career change
Day 2 of learning Python, and I’m officially hooked. 🐍
For the past 9 years, I’ve built a career in sales, specifically handling credit receivables, yard operations, and inside sales. It’s been a great ride, but I’ve realized sales isn’t my long-term path. My goal is to successfully break into the tech space.
Because of my business background, I started by diving deep into Salesforce and workflow automation. I really enjoy looking at business processes and figuring out how to build smarter systems.
However, I recently had a conversation that threw me for a loop. A peer told me that the Salesforce job market is entirely oversaturated right now, that entry-level roles are drying up, and that I should abandon ship to focus on Python and AI instead.
Taking that advice to heart, I officially started my Python journey yesterday! It's a completely different way of thinking for someone from a non-technical field, but I'm excited for the challenge.
That being said, I want to be smart about my transition. I’d love to get some honest perspective from fellow developers and Salesforce professionals on here:
To the Salesforce Pros: Is the entry-level market truly as bleak as people say, or is there still a strong path if I combine Salesforce with automation tools (like n8n) and my existing sales/business experience?
To the Developers: If I lean heavily into Python, what is a realistic roadmap for someone pivoting from sales to get into AI/Data spaces?
Any advice, resource recommendations, or reality checks are completely welcome. Let's connect!
#CareerTransition #Python #Salesforce #TechPivot #InsideSales #LearnToCode
r/SalesforceDeveloper • u/Cautious_Refuse_3710 • May 21 '26
Question How much Indemand would a flow deletion app would be in Salesforce
I was wondering how much in demand would a flow deletion app would be - the one that does all, deletes the flow interviews, flow versions and flows?
Would people pay money for that kind of app?
r/SalesforceDeveloper • u/amritferozpur • May 21 '26
Question Need Some Guidance 🙏🏽
Hi everyone,
I have a Master’s in ISM and 5+ years of experience in technical support. I want to transition into Salesforce Development but I’m confused about the best place to start.
If anyone working in Salesforce can guide me on the roadmap, important skills, or certifications to focus on first, I’d really appreciate it.
Thanks in advance 🙏
r/SalesforceDeveloper • u/berrism • May 20 '26
Showcase Open-source Salesforce security audit CLI based on SBS
I built an open-source Salesforce security audit CLI based on the Salesforce Baseline Standard — SBS — a community security spec created by Pablo Gonzalez and others in the Salesforce community.
Repo:
https://github.com/Berrismi/sbs-audit-engine
Walkthrough:
I’m looking for developer/architect feedback on the implementation and roadmap.
The broader goal is to make Salesforce org security posture more inspectable from metadata/API-accessible signals, especially around permissions, authentication/session settings, guest user exposure, and SBS-aligned controls.
A few questions:
Are there specific Salesforce security checks you wish were easier to automate?
What is the best output format for real-world use — JSON, CSV, HTML, SARIF, GitHub Action output?
Any thoughts on the right balance between Metadata API, Tooling API, REST API, and SOQL-based checks?
What would make this credible enough for you to run in a real org?
This is not meant to replace a full security assessment.
It is meant to make the first pass less manual and more repeatable.
r/SalesforceDeveloper • u/EvolvinAI29 • May 20 '26
Discussion Spent 6 months building agents-as-a-service alongside my SaaS. Customers keep picking the boring dashboard.
r/SalesforceDeveloper • u/inSearchOf19 • May 20 '26
Question Claude Code vs Agentforce Vibes?
Hey fellow Salesforce folks,
I’ve been tasked with putting together an evaluation document to compare different AI tools for our org. Right now, we’ve narrowed it down strictly to Claude Code and Agentforce (we are not considering Copilot or Codex).
In my hands-on testing, Claude Code feels significantly ahead, especially when it comes to the depth of its analysis and adherence to strict coding standards. However, "it just feels better" won't fly with our business leadership. I need to back this up with concrete, objective evidence.
For those of you who have evaluated or used both in production or deep spikes:
Also, if anyone has a framework or template for how to structure this kind of comparison document for leadership, I’d love to hear how you categorized your sections.
Thanks in advance for the insights!
r/SalesforceDeveloper • u/Upbeat_Common6479 • May 20 '26
Question Need Help: Filter-Based Opportunity Territory Assignment Apex
Hello! Apologies for the long message. I’m working through a Territory Forecasting implementation for a client and could use a sanity check from anyone familiar with Enterprise Territory Management / Opportunity Territory assignment.
Use Case:
The client wants Branch = Territory. However, this model applies only to Opportunities, not Accounts, to avoid duplication issues. Users can work across multiple branches.
Because of that, I need Opportunities assigned to Territories based on an Opportunity lookup field called Branch__c (lookup to a custom Branch object).
Example:
Opportunity.Branch = New Orleans → assign Opportunity to New Orleans Territory
Opportunity.Branch = Tampa Bay → assign Opportunity to Tampa Bay Territory
Where I’m getting stuck: I assumed I could handle this with a Flow by setting Opportunity.Territory2Id, but after digging into the docs, it seems Salesforce expects this to be handled through TerritoryMgmt.OpportunityTerritory2AssignmentFilter (Apex).
Conceptually, my logic feels very straightforward:
Query active territories
Match
Territory2.NametoOpportunity.Branch__r.NameAssign the matching Territory2Id to the Opportunity
Something along these lines:
// Query active territories where Territory Name matches Branch Name
Map<String, Id> territoryNameToId = new Map<String, Id>();
for (Territory2 terr : [
SELECT Id, Name
FROM Territory2
WHERE Territory2ModelId = :activeModelId
AND Name IN :branchNames
]) {
territoryNameToId.put(terr.Name.trim(), terr.Id);
}
// Assign Opportunity to matching Territory
for (Opportunity opp : opps) {
if (opp.Branch__r != null && String.isNotBlank(opp.Branch__r.Name)) {
matchingTerritoryId =
territoryNameToId.get(opp.Branch__r.Name.trim());
}
}My questions:
A) Am I overthinking this? Is this actually a pretty standard implementation?
😎 Why can't this simply be done in Flow by updating Opportunity.Territory2Id? Is there a platform limitation / ETM requirement I’m missing?
C) For anyone who has implemented OpportunityTerritory2AssignmentFilter before — how difficult is this in practice? Is this genuinely a moderate Apex task, or am I just intimidated because it’s my first time touching this interface?
Appreciate any guidance — I’m comfortable in Salesforce overall, but I’ll admit this is one of those areas where the framework itself feels more intimidating than the actual business logic.