15 June 2016

Auto Account Ownership based on geography

I've created rules to assign the account owner based on states and countries for our company.
In the back of my mind I've always thought maybe one of the Territory Management features out of the box would be sufficient.  But I could see the whole process in my head before any work was done so I just built it.

Step one.  Custom Fields to assign a Region and Region - Global to each account.  The rules are based on the existing definitions of each region our company already had in place.  Six Regions in the US.  Multiple Regions in Europe.  And a half dozen or so Global Regions that the sub Regions fit into.

region sub  region global
AsiaPac (CAP) Asia Pacific
Rest of Asia Asia Pacific
Antartica International
Latin America Latin America
North America North America
Rest of North America North America
Africa South Africa & Africa
CQS South Africa & Africa
Europe UK & Europe
UK & Nordic UK & Europe

AND

region segment
Canada North America
Central North America
Mid-Atlantic North America
Northeast North America
South Central North America
Southeast North America
West North America

To assign the region and region - global fields based on the state/country I created formulas on the fields themselves.  They actually fit just under the character limits for formula fields. 

Region: 

IF(
    OR(
        AND(
            ISBLANK(BillingState),
            BillingCountry = "United States"
        ),
        AND(
            ISBLANK(BillingState),
            ISBLANK(BillingCountry)
        )
    ),
    "None",


IF( 
BillingCountry = "Canada", 
"Canada", 

if( 
    contains("Algeria:Angola:Benin:Burundi:Cape Verde:Central African Republic:Chad:Comoros:Congo:Congo, the Democratic Republic of the:Cote d'Ivoire:Djibouti:Egypt:Equatorial Guinea:Gabon:Guinea:Madagascar:Mali:Mauritania:Mayotte:Morocco:Mozambique:Niger:Reunion:Sao Tome and Principe:Senegal:Sierra Leone:Somalia:Sudan:Tanzania, United Republic of:Togo:Tunisia:Libya:South Sudan", BillingCountry), 
    "Africa", 

IF( 
    CONTAINS("China:Australia:Malaysia:New Zealand:Singapore", BillingCountry), 
    "AsiaPac (CAP)", 

IF( 
    CONTAINS("Belgium:France:Germany:Italy:Luxembourg:Netherlands:Portugal:Spain:Switzerland:Aland Islands:Albania:Andorra:Austria:Belarus:Bosnia and Herzegovina:Bulgaria:Croatia:Czech Republic:Faroe Islands:Gibraltar:Greece:Guernsey:Holy See (Vatican City State):Hungary:Iceland:Liechtenstein:Malta:Moldova, Republic of:Monaco:Montenegro:Poland:Romania:Russian Federation:San Marino:Serbia:Slovakia:Slovenia:Turkey:Ukraine:Macedonia, the former Yugoslav Republic of:Saint Helena, Ascension and Tristan da Cunha:Cyprus", BillingCountry), 
"Europe", 

IF( 
contains("Falkland Islands (Malvinas):Argentina:Brazil:Chile:Colombia:Ecuador:French Guiana:Guyana:Paraguay:Peru:Suriname:Uruguay:Bolivia, Plurinational State of:Venezuela, Bolivarian Republic of", BillingCountry), 
"Latin America", 

IF( 
contains("Virgin Islands, British:Anguilla:Antigua and Barbuda:Aruba:Bahamas:Barbados:Belize:Bermuda:Cayman Islands:Costa Rica:Cuba:Dominica:Dominican Republic:El Salvador:Greenland:Grenada:Guadeloupe:Guatemala:Haiti:Honduras:Guam:Jamaica:Martinique:Mexico:Montserrat:Nicaragua:Panama:Puerto Rico:Saint Kitts and Nevis:Saint Lucia:Saint Pierre and Miquelon:Saint Vincent and the Grenadines:Trinidad and Tobago:Turks and Caicos Islands:Bonaire, Sint Eustatius and Saba:Curaçao:Saint Martin (French part):Sint Maarten (Dutch part)", BillingCountry), 
"Rest of North America", 

IF( 
contains("Afghanistan:Armenia:Azerbaijan:Bahrain:Bangladesh:Bhutan:British Indian Ocean Territory:Brunei Darussalam:Cambodia:Christmas Island:Cocos (Keeling) Islands:Cook Islands:Fiji:French Polynesia:Georgia:India:Indonesia:Iran, Islamic Republic of:Iraq:Israel:Japan:Jordan:Kazakhstan:Kiribati:Korea, Democratic People's Republic of:Korea, Republic of:Kuwait:Kyrgyzstan:Lao People's Democratic Republic:Lebanon:Macao:Maldives:Mongolia:Myanmar:Nauru:Nepal:New Caledonia:Niue:Norfolk Island:Oman:Pakistan:Papua New Guinea:Philippines:Pitcairn:Qatar:Samoa:Saudi Arabia:Solomon Islands:Sri Lanka:Syrian Arab Republic:Taiwan:Tajikistan:Thailand:Timor-Leste:Tokelau:Micronesia:Tonga:Turkmenistan:Tuvalu:United Arab Emirates:Uzbekistan:Vanuatu:Yemen:Palestine:Viet Nam", BillingCountry), 
"Rest of Asia", 

IF( 
contains("Botswana:Cameroon:Eritrea:Ethiopia:Gambia:Ghana:Kenya:Lesotho:Liberia:Malawi:Mauritius:Namibia:Nigeria:Rwanda:Seychelles:South Africa:Swaziland:Uganda:Zambia:Zimbabwe", BillingCountry), 
"CQS", 

IF( 
contains("Estonia:Latvia:Lithuania:Jersey:Denmark:Finland:Norway:Sweden:Ireland:Isle of Man:United Kingdom", BillingCountry), 
"UK & Nordic", 

IF(
contains("DE:KY:MD:NC:OH:SC:VA:WV:DC",BillingState),
"Mid-Atlantic",

IF(
contains("AK:AZ:CA:CO:HI:ID:MT:NV:OR:UT:WA:WY",BillingState),
"West",

IF(
contains("CT:ME:MA:NH:NJ:NY:PA:RI:VT",BillingState),
"Northeast",

IF(
contains("AL:AR:FL:GA:LA:MS:TN:VI",BillingState),
"Southeast",

IF(
contains("IL:IN:IA:MI:MN:MO:NE:ND:SD:WI",BillingState),
"Central",

IF(
contains("KS:NM:OK:TX",BillingState),
"South Central",


"NONE"))))))))))))))))

AND   Region - Global

IF(
   ISBLANK(BillingCountry),
    "None",

IF(
contains("United States:Canada",BillingCountry),
"North America", 

if(
contains("Algeria:Angola:Benin:Burkina Faso:Burundi:Cape Verde:Central African Republic:Chad:Comoros:Congo:Congo, the Democratic Republic of the:Cote d'Ivoire:Djibouti:Egypt:Equatorial Guinea:Gabon:Guinea:Guinea-Bissau:Madagascar:Mali:Mauritania:Mayotte:Morocco:Mozambique:Niger:Reunion:Sao Tome and Principe:Senegal:Sierra Leone:Somalia:Sudan:Tanzania, United Republic of:Togo:Tunisia:Western Sahara:Libya:South Sudan", BillingCountry),
"South Africa & Africa",

IF(
CONTAINS("China:Australia:Malaysia:New Zealand:Singapore", BillingCountry),
"Asia Pacific",

IF(
CONTAINS("Belgium:France:Germany:Italy:Luxembourg:Netherlands:Portugal:Spain:Switzerland:Aland Islands:Albania:Andorra:Austria:Belarus:Bosnia and Herzegovina:Bulgaria:Croatia:Czech Republic:Faroe Islands:Gibraltar:Greece:Guernsey:Holy See (Vatican City State):Hungary:Iceland:Liechtenstein:Malta:Moldova, Republic of:Monaco:Montenegro:Poland:Romania:Russian Federation:San Marino:Serbia:Slovakia:Slovenia:Svalbard and Jan Mayen:Turkey:Ukraine:Macedonia, the former Yugoslav Republic of:Saint Helena, Ascension and Tristan da Cunha:Cyprus", BillingCountry),
"UK & Europe",

IF(
CONTAINS("Falkland Islands (Malvinas):Argentina:Brazil:Chile:Colombia:Ecuador:French Guiana:Guyana:Paraguay:Peru:Suriname:Uruguay:Bolivia, Plurinational State of:Venezuela, Bolivarian Republic of", BillingCountry),
"Latin America",

IF(
CONTAINS("Virgin Islands, British:Anguilla:Antigua and Barbuda:Aruba:Bahamas:Barbados:Belize:Bermuda:Cayman Islands:Costa Rica:Cuba:Dominica:Dominican Republic:El Salvador:Greenland:Grenada:Guadeloupe:Guatemala:Haiti:Honduras:Jamaica:Martinique:Mexico:Montserrat:Nicaragua:Panama:Puerto Rico:Saint Kitts and Nevis:Saint Lucia:Saint Pierre and Miquelon:Saint Vincent and the Grenadines:Trinidad and Tobago:Turks and Caicos Islands:Bonaire, Sint Eustatius and Saba:Curaçao:Saint Barthélemy:Saint Martin (French part):Sint Maarten (Dutch part)", BillingCountry),
"North America",

IF(
CONTAINS("Afghanistan:Armenia:Micronesia:Azerbaijan:Bahrain:Bangladesh:Bhutan:British Indian Ocean Territory:Brunei Darussalam:Cambodia:Christmas Island:Cocos (Keeling) Islands:Cook Islands:Fiji:French Polynesia:Georgia:Guam:India:Indonesia:Iran, Islamic Republic of:Iraq:Israel:Japan:Jordan:Kazakhstan:Kiribati:Korea, Democratic People's Republic of:Korea, Republic of:Kuwait:Kyrgyzstan:Lao People's Democratic Republic:Lebanon:Macao:Maldives:Mongolia:Myanmar:Nauru:Nepal:New Caledonia:Niue:Norfolk Island:Oman:Pakistan:Papua New Guinea:Philippines:Pitcairn:Qatar:Samoa:Saudi Arabia:Solomon Islands:Sri Lanka:Syrian Arab Republic:Taiwan:Tajikistan:Thailand:Timor-Leste:Tokelau:Tonga:Turkmenistan:Tuvalu:United Arab Emirates:Uzbekistan:Vanuatu:Wallis and Futuna:Yemen:Palestine:Viet Nam", BillingCountry),
"Asia Pacific",

IF(
CONTAINS("Botswana:Cameroon:Eritrea:Ethiopia:Gambia:Ghana:Kenya:Lesotho:Liberia:Malawi:Mauritius:Namibia:Nigeria:Rwanda:Seychelles:South Africa:Swaziland:Uganda:Zambia:Zimbabwe", BillingCountry), 
"South Africa & Africa",

IF(
Contains("Estonia:Latvia:Lithuania:Jersey:Denmark:Finland:Norway:Sweden:Ireland:Isle of Man:United Kingdom", BillingCountry),
"UK & Europe",

"NONE"))))))))))

DONE

Once these fields are set I can base ownership on the population of these fields. 

here's an example of some of the filters. 



At the top of the flow I have some exceptions to the rules which is nice because I can be in complete control of what accounts go to who. 

If anyone thinks I should be doing this a different way I'm open to suggestions.  I was just thinking I need to explore Territory Management again in the sandbox and see if it's easier. 

This works for now though. 






No comments:

Post a Comment