+ Start a Discussion
Jamuna Mani 6Jamuna Mani 6 

Enterprise Territory Management - Issue with the Apex class "OppTerrAssignDefaultLogicFilter"

We recently implemented Enterprise Territory Management in our organization. I have used the "OppTerrAssignDefaultLogicFilter" apex class to display the territory name in the opportunities. When the button "Run Opportunity Filter" is clicked, the apex class populates the territory name on the  opportunities . I am observing the following issues  with the Apex class:

- Even though the account has only single territory with the maximum priority, the associated opportunity doesn't get the territory assigned
-Under the same account one opportunity gets territory assigned whereas the other opportunity doesn't get territory assigned
- I have even tried to run this class for small group of records. Still not all the records get the territory assigned.

Note: We have only one Territory model active
Best Answer chosen by Andy Boettcher
Andy BoettcherAndy Boettcher
You will want to open a support case with Salesforce to discuss this matter.

All Answers

Andy BoettcherAndy Boettcher
You will want to open a support case with Salesforce to discuss this matter.
This was selected as the best answer
Becky Hammond 6Becky Hammond 6
Jamuna - was support able to help you with this?  I'm having the exact same problem but since we don't have premier support, Salesforce won't help.  
EJ AufderheideEJ Aufderheide
Jamuna, Becky - Same issue here.  Were you able to get this resolved?
 
Becky Hammond 6Becky Hammond 6
Hi EJ - I posted the resolution that worked for me here:

https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MJ7YIAW

Basically, I commented out these 2 lines in the code:


 //&& (tp.territory2Id != opp.Territory2Id))
 //&& (tp.moreTerritoriesAtPriority == false)

If you have more than one territory per account, you may not want to do that.  
EJ AufderheideEJ Aufderheide
That fixed my issue (i only have one territory per account as well).  It would be great if someone would review this apex code and fix it for those that have multiple territories per account.  Considering Salesforce sells this as part of the enterprise territory management it would be nice if it works so other don't get the run around like we have.

Thanks for the help Becky.  I look forward to an update to the code.​
UnrealJdvUnrealJdv
I did the same Becky, had to comment out the "&& (tp.territory2Id != opp.Territory2Id))" clause because that just 'inverts' your previously assigned Opps to be unassigned. e.g.if it doesn't work the first time you run it when you run it a second time the logic unassigns the ones that were successful during the first pass.

Agree with EJ and I've had the runaround on this too, sometimes the job just fails (albeit only partially) but there's no further information provided as to why some Opps just don't get updated even though they are included in the filter. 
Nitish TalekarNitish Talekar
Hi,

For this, check out blog Territory Management In Salesforce Can Increase Your Profit (http://howtodoitinsalesforce.blogspot.in/2017/01/territory-management-in-salesforce-can.html) !

Thanks,