<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Apex Sharing &#8211; Jitendra Zaa</title>
	<atom:link href="https://www.jitendrazaa.com/blog/tag/apex-sharing/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.jitendrazaa.com/blog</link>
	<description>AI, Salesforce, ServiceNow &#38; Enterprise Tech Guides</description>
	<lastBuildDate>Sun, 24 Feb 2019 15:44:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">87744916</site><atom:link rel="search" type="application/opensearchdescription+xml" title="Search Jitendra Zaa" href="https://www.jitendrazaa.com/blog/wp-json/opensearch/1.1/document" />	<item>
		<title>Enterprise Territory Management &#8211; Key Notes</title>
		<link>https://www.jitendrazaa.com/blog/salesforce/enterprise-territory-management-key-notes/</link>
					<comments>https://www.jitendrazaa.com/blog/salesforce/enterprise-territory-management-key-notes/#respond</comments>
		
		<dc:creator><![CDATA[Jitendra]]></dc:creator>
		<pubDate>Tue, 12 Feb 2019 03:45:11 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[Apex Sharing]]></category>
		<category><![CDATA[Forecast]]></category>
		<category><![CDATA[Territory Management]]></category>
		<guid isPermaLink="false">https://www.jitendrazaa.com/blog/?p=6777</guid>

					<description><![CDATA[How to use Apex based sharing to share opportunity using Territories]]></description>
										<content:encoded><![CDATA[
<ul class="justify wp-block-list"><li>Enterprise Territory management is used to share Account and its related opportunity and Cases.</li><li>Account can have multiple Territories.</li><li>User can have multiple Territories</li><li>Opportunity can have only 1 Territory. Think about it &#8211; If Opportunity allowed to have multiple Territory, how revenue would be split between multiple Territory and what would be business rules ?</li><li>Territory enables &#8220;My Territories&#8221; and &#8220;My Team&#8217;s Territory&#8221; filter in Account and Opportunity list View.</li><li>While creating Territory, we can decide access to Account, Opportunity and Case. Depending on OWD, access can be private, read only and read write.</li><li>Enterprise Territory Management does not support overlay forecast unlike Roles. However we can create report on Opportunity split object.</li><li>Overlay forecast (Revenue sharing) is not supported because Opportunity can have only one territory and therefore only 1 revenue maker.</li><li>Maximum Territory that can be defined is around 99k unlike maximum role 10k.</li><li>Custom Field (but not lookup) can be created in Territory2 object.</li><li>Territory related list appears on user and Account records.</li><li>You cannot create lookup to Territory objects.</li><li>Territory to Opportunity can be assigned using Apex class plugin</li></ul>



<h2 class="wp-block-heading">Enable Territory based Forecast</h2>



<ol class="justify wp-block-list"><li>Mark user as &#8220;Allowed Forecast&#8221;</li><li>Add user as Territory Team member</li><li>Add user as Forecast Manager in Territory</li></ol>



<h2 class="wp-block-heading">Apex Based Sharing of Opportunity using Territory</h2>



<p class="justify">For <a href="https://www.jitendrazaa.com/blog/salesforce/apex-based-sharing-in-salesforce/">Apex based sharing</a>, we use user of public group Id to share record. If we want to share Opportunity using Territory then there is quick code for that. If we click on manual share button on Opportunity, it will show an option to choose between user, public group, territory and territory with subordinates. </p>



<p class="justify">There is no clear documentation, but what I found that when we share using Territory, <strong>Salesforce internally creates public group for that territory </strong>and assigns that public group to Opportunity.</p>



<p class="justify">So, first step is to find public group created for territory. Below code showcase how it can be done.</p>



<script src="https://gist.github.com/JitendraZaa/f973e500b6ee5e83995c367b7e1a54a8.js"></script>



<p><strong>References :</strong></p>



<ul class="wp-block-list"><li><a href="https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_opportunityshare.htm">OpportunityShare</a> object reference</li><li><a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_understanding.htm">Understanding</a> Sharing</li><li><a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm">Sharing records</a> using Apex</li></ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.jitendrazaa.com/blog/salesforce/enterprise-territory-management-key-notes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6777</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: www.jitendrazaa.com @ 2026-06-19 02:28:52 by W3 Total Cache
-->