While that code should work, you really want to look at the custom setting as the object of ‘truth’, as that will determine the expected behavior in the rest of the org. The npe01Account_Processorc field in the npe01Contacts_And_Orgs_Settingsc setting will either be “One-to-One” or “Individual”
From: David Habib [mailto:davidhabib@groundwire.org]
Sent: Monday, July 02, 2012 2:59 PM
To: Matthew Scholtz; Kevin Bromer
Cc: Eric Magnuson (GW)
Subject: RE: detecting 1-to-1 vs bucket
This is the logic I stole from NPSP several years ago that is in Auction’s code:
//From the Non Profit Starter Pack.
//One-to-One value for system processor field
private static String ONE_TO_ONE_PROCESSOR = 'One-to-One';
//From the Non Profit Starter Pack.
//method to tell which model we're currently in for Accounts
public static boolean isOneToOne() {
boolean isOneToOneModel;
isOneToOneModel = false;
Map<String, Schema.SObjectField> M = Schema.SObjectType.Contact.fields.getMap();
Schema.SObjectField fld = M.get('npe01__SystemAccountProcessor__c');
if (fld == null) return false;
//Schema.DescribeFieldResult F = Schema.sObjectType.Contact.fields.npe01__SystemAccountProcessor__c;
Schema.DescribeFieldResult F = fld.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
for(Schema.PicklistEntry pe : P){
if (pe.isDefaultValue()){
if(pe.getValue()==ONE_TO_ONE_PROCESSOR){ isOneToOneModel = true;}
}
}
return isOneToOneModel;
}
Sure hope this code is still correct!!
DaveH
From: Matthew Scholtz
Sent: Monday, July 02, 2012 11:54 AM
To: Kevin Bromer kbromer@salesforce.com (kbromer@salesforce.com)
Cc: David Habib; Eric Magnuson (GW)
Subject: detecting 1-to-1 vs bucket
Hey Kevin,
How’s it going? Quick qq for you: what’s the proper way in code to detect whether someone is using the 1-to-1 or bucket model? I noticed that in addition to the setting, there’s a field on each contact that seems to be related to this? Where should I look? Is it possible that some contacts will be using one model and some the other? (if they switched the setting at some point while using NPSP?)
To our surprise, several of our upcoming beta testers for our engagement tracker are using the 1-to-1 model, so we need to support it.
From Kevin Bromer:
While that code should work, you really want to look at the custom setting as the object of ‘truth’, as that will determine the expected behavior in the rest of the org. The npe01Account_Processorc field in the npe01Contacts_And_Orgs_Settingsc setting will either be “One-to-One” or “Individual”
From: David Habib [mailto:davidhabib@groundwire.org] Sent: Monday, July 02, 2012 2:59 PM To: Matthew Scholtz; Kevin Bromer Cc: Eric Magnuson (GW) Subject: RE: detecting 1-to-1 vs bucket
This is the logic I stole from NPSP several years ago that is in Auction’s code:
Sure hope this code is still correct!! DaveH
From: Matthew Scholtz Sent: Monday, July 02, 2012 11:54 AM To: Kevin Bromer kbromer@salesforce.com (kbromer@salesforce.com) Cc: David Habib; Eric Magnuson (GW) Subject: detecting 1-to-1 vs bucket
Hey Kevin,
How’s it going? Quick qq for you: what’s the proper way in code to detect whether someone is using the 1-to-1 or bucket model? I noticed that in addition to the setting, there’s a field on each contact that seems to be related to this? Where should I look? Is it possible that some contacts will be using one model and some the other? (if they switched the setting at some point while using NPSP?)
To our surprise, several of our upcoming beta testers for our engagement tracker are using the 1-to-1 model, so we need to support it.
Thanks much! Matthew