We have a field on the account, Market_Segment__c, that is controlled by the following piece of code:
public static string getMarketSegment(integer employeeCount){
if(employeeCount < 201)
return 'SMB';
else if(employeeCount < 1001)
return 'MID';
else if(employeeCount < 4501)
return 'MAJ';
else return 'ENT';
}
The problem is, the banding for the different segments changes every year, meaning we have to update the apex code every year, at the beginning of the new fiscal year, when we're usually (trying to) have a code freeze in effect.
I'd like to use an alternative approach that would require NOT having to update this code so often. Trying to remove this piece of code causes issues because of a complex interdependency on other classes that, so far, has been more trouble to untangle than it's worth.
I've been looking at using custom metadata. I've created a custom metadata type, Market Segment Threshold, with a custom field Threshold, and I was thinking I could replace the numerical values in the code with a reference to the metadata.
My questions is, first, is this the best/correct way of approaching this? And if so, how do I go about this? do I need SOQL queries or...? Thanks!