Skip to content

Commit

Permalink
SfdcClient: configuration enabled record type fields
Browse files Browse the repository at this point in the history
  • Loading branch information
VSydor authored and brmeyer committed Aug 11, 2024
1 parent 3c8e6d1 commit 3687d27
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
16 changes: 12 additions & 4 deletions src/main/java/com/impactupgrade/nucleus/client/SfdcClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ public SfdcClient(Environment env, String username, String password, boolean isS
boolean npsp = env.getConfig().salesforce.npsp;

ACCOUNT_FIELDS = "id, OwnerId, Owner.Id, Owner.IsActive, name, phone, BillingStreet, BillingCity, BillingPostalCode, BillingState, BillingCountry, ShippingStreet, ShippingCity, ShippingPostalCode, ShippingState, ShippingCountry";
CAMPAIGN_FIELDS = "id, name, parentid, ownerid, owner.id, owner.isactive, StartDate, EndDate, RecordTypeId, RecordType.Id, RecordType.Name";
CAMPAIGN_FIELDS = "id, name, parentid, ownerid, owner.id, owner.isactive, StartDate, EndDate";
if (env.getConfig().salesforce.campaignHasRecordTypes) {
CAMPAIGN_FIELDS += ", RecordTypeId, RecordType.Id, RecordType.Name";
}
CONTACT_FIELDS = "Id, AccountId, OwnerId, Owner.Id, Owner.Name, Owner.IsActive, FirstName, LastName, Title, Account.Id, Account.Name, Account.BillingStreet, Account.BillingCity, Account.BillingPostalCode, Account.BillingState, Account.BillingCountry, Account.ShippingStreet, Account.ShippingCity, Account.ShippingPostalCode, Account.ShippingState, Account.ShippingCountry, name, email, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, CreatedDate, HomePhone, MobilePhone, Phone";
LEAD_FIELDS = "Id, FirstName, LastName, Email, OwnerId, Owner.Id, Owner.Name, Owner.IsActive";
DONATION_FIELDS = "id, AccountId, Account.Id, Account.Name, ContactId, Amount, Name, RecordTypeId, RecordType.Id, RecordType.Name, CampaignId, Campaign.ParentId, CloseDate, StageName, Type, Description, OwnerId, Owner.Id, Owner.IsActive";
Expand All @@ -116,10 +119,15 @@ public SfdcClient(Environment env, String username, String password, boolean isS
// has them due to the Household vs. Organization default, but commercial entities have a flatter setup.
// IF we need these commercially, needs to become a configurable option in env.json. Unfortunately, SFDC
// returns a query error if you try to query them but no record types exist for that object.
ACCOUNT_FIELDS += ", RecordTypeId, RecordType.Id, RecordType.Name, npo02__NumberOfClosedOpps__c, npo02__TotalOppAmount__c, npo02__LastCloseDate__c, npo02__LargestAmount__c, npo02__OppsClosedThisYear__c, npo02__OppAmountThisYear__c, npo02__FirstCloseDate__c";
if (env.getConfig().salesforce.accountHasRecordTypes) {
ACCOUNT_FIELDS += ", RecordTypeId, RecordType.Id, RecordType.Name";
CONTACT_FIELDS += ", Account.RecordTypeId, Account.RecordType.Id, Account.RecordType.Name";
DONATION_FIELDS += ", Account.RecordTypeId, Account.RecordType.Id, Account.RecordType.Name";
}
ACCOUNT_FIELDS += ", npo02__NumberOfClosedOpps__c, npo02__TotalOppAmount__c, npo02__LastCloseDate__c, npo02__LargestAmount__c, npo02__OppsClosedThisYear__c, npo02__OppAmountThisYear__c, npo02__FirstCloseDate__c";
// TODO: Same point about NPSP.
CONTACT_FIELDS += ", Account.RecordTypeId, Account.RecordType.Id, Account.RecordType.Name, account.npo02__NumberOfClosedOpps__c, account.npo02__TotalOppAmount__c, account.npo02__FirstCloseDate__c, account.npo02__LastCloseDate__c, account.npo02__LargestAmount__c, account.npo02__OppsClosedThisYear__c, account.npo02__OppAmountThisYear__c, npe01__Home_Address__c, npe01__WorkPhone__c, npe01__PreferredPhone__c, npe01__HomeEmail__c, npe01__WorkEmail__c, npe01__AlternateEmail__c, npe01__Preferred_Email__c";
DONATION_FIELDS += ", npe03__Recurring_Donation__c, Account.RecordTypeId, Account.RecordType.Id, Account.RecordType.Name";
CONTACT_FIELDS += ", account.npo02__NumberOfClosedOpps__c, account.npo02__TotalOppAmount__c, account.npo02__FirstCloseDate__c, account.npo02__LastCloseDate__c, account.npo02__LargestAmount__c, account.npo02__OppsClosedThisYear__c, account.npo02__OppAmountThisYear__c, npe01__Home_Address__c, npe01__WorkPhone__c, npe01__PreferredPhone__c, npe01__HomeEmail__c, npe01__WorkEmail__c, npe01__AlternateEmail__c, npe01__Preferred_Email__c";
DONATION_FIELDS += ", npe03__Recurring_Donation__c";
RECURRINGDONATION_FIELDS = "id, name, npe03__Recurring_Donation_Campaign__c, npe03__Recurring_Donation_Campaign__r.Name, npe03__Next_Payment_Date__c, npe03__Installment_Period__c, npe03__Amount__c, npe03__Open_Ended_Status__c, npe03__Contact__c, npe03__Contact__r.Id, npe03__Contact__r.Name, npe03__Contact__r.Email, npe03__Contact__r.Phone, npe03__Schedule_Type__c, npe03__Date_Established__c, npe03__Organization__c, npe03__Organization__r.Id, npe03__Organization__r.Name, OwnerId, Owner.Id, Owner.IsActive";
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ public static class Salesforce extends Platform {
public boolean npsp = true;
// some differences in fields/operations
public boolean enhancedRecurringDonations = false;
public boolean accountHasRecordTypes = false;
public boolean campaignHasRecordTypes = false;

public boolean sandbox = false;
public String url = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,13 @@ public static CrmImportEvent fromClassy(Map<String, String> _data) {
importEvent.contactMailingZip = data.get("Billing Postal Code");
importEvent.contactMailingCountry = data.get("Billing Country");

if (!Strings.isNullOrEmpty(data.get("Campaign ID"))) {
CampaignMembership campaignMembership = new CampaignMembership();
// TODO: more likely to be an extref?
campaignMembership.campaignId = data.get("Campaign ID");
importEvent.contactCampaigns.add(campaignMembership);
}
// TODO: more likely to be an extref?
// TODO: rework this condition - triggers 'Campaign ID: id value of incorrect type: 87647' error
// if (!Strings.isNullOrEmpty(data.get("Campaign ID"))) {
// CampaignMembership campaignMembership = new CampaignMembership();
// campaignMembership.campaignId = data.get("Campaign ID");
// importEvent.contactCampaigns.add(campaignMembership);
// }
if (!Strings.isNullOrEmpty(data.get("Campaign Name"))) {
CampaignMembership campaignMembership = new CampaignMembership();
campaignMembership.campaignName = data.get("Campaign Name");
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/impactupgrade/nucleus/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ public static ZonedDateTime toZonedDateTime(Long epochSecond, String timezoneId)
}

public static Calendar toCalendar(ZonedDateTime zonedDateTime, String explicitTimezoneId) {
if (zonedDateTime == null) {
return null;
}
if (!Strings.isNullOrEmpty(explicitTimezoneId)) {
zonedDateTime = zonedDateTime.withZoneSameInstant(ZoneId.of(explicitTimezoneId));
}
return zonedDateTime != null ? GregorianCalendar.from(zonedDateTime) : null;
return GregorianCalendar.from(zonedDateTime);
}

public static String cleanUnicode(String s) {
Expand Down

0 comments on commit 3687d27

Please sign in to comment.