Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion force-app/main/default/classes/SummitEventsContactMatching.cls
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ public without sharing class SummitEventsContactMatching {
doCRUD crud = new doCRUD();

if (matches.isEmpty() && noMatchBehavior.startsWithIgnoreCase('Create')) {
//remove values of mappings set to match only so that they are not inserted into the new record
newObj = removeMatchOnlyFields(newObj, customMappingType, mappings, sObjectType);
crud.addRecord(newObj);
reg.put(fieldAPIName, newObj.Id);
reg.put(newFieldAPIName, true);
Expand Down Expand Up @@ -292,7 +294,7 @@ public without sharing class SummitEventsContactMatching {
mappedMatchingMethods = new Map<String, List<SObject>>();
if (mappedMatchingMethods.isEmpty()) {
if (matchingMethods.size() > 0) {
String query = 'SELECT Source_Value__c, Source_Type__c, ' + fieldAPIName + ', ' + sourceValue + ' FROM ' + namespace + sObjectType + ' WHERE ' + fieldAPIName + ' IN :matchingMethods';
String query = 'SELECT Source_Value__c, Source_Type__c, Matching_Only__c, ' + fieldAPIName + ', ' + sourceValue + ' FROM ' + namespace + sObjectType + ' WHERE ' + fieldAPIName + ' IN :matchingMethods';
List<SObject> results = Database.query(query);
for (SObject mapping : results) {
String method = (String) mapping.get(fieldAPIName);
Expand Down Expand Up @@ -375,6 +377,36 @@ public without sharing class SummitEventsContactMatching {
return record;
}

@TestVisible
private static SObject removeMatchOnlyFields(SObject record, String matchingMethod, Map<String, List<SObject>> mappings, String sObjectType) {
String namespace = SummitEventsNamespace.StrTokenNSPrefix('');
String objFieldAPIName = getFieldAPINameForObjectType(sObjectType);

if (mappings.containsKey(matchingMethod)) {
List<SObject> mappingList = mappings.get(matchingMethod);
for (SObject mapping : mappingList) {
Boolean matchingOnly = (Boolean) mapping.get(namespace + 'Matching_Only__c');
if (matchingOnly != null && matchingOnly) {
String fieldAPIName = (String) mapping.get(namespace + objFieldAPIName);
// Set the field to null to remove it from the record before insert
record.put(fieldAPIName, null);
}
}
}
return record;
}

private static String getFieldAPINameForObjectType(String sObjectType) {
if (sObjectType.equals('Contact')) {
return 'Contact_Field_API_Name__c';
} else if (sObjectType.equals('Account')) {
return 'Person_Account_Field_API_Name__c';
} else if (sObjectType.equals('Lead')) {
return 'Lead_Field_API_Name__c';
}
return null;
}

private static Account makePerson(Summit_Events_Registration__c reg, String customMappingType, Map<String, List<SObject>> contactMappings) {
Account personAccount = new Account();
Boolean personAccountActive = SummitEventsShared.personAccountsEnabled();
Expand Down
43 changes: 16 additions & 27 deletions force-app/main/default/classes/SummitEventsRegistration.cls
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@ public class SummitEventsRegistration {
List<Summit_Events_Registration__c> affectedRegs = new List<Summit_Events_Registration__c>();

String namespace = SummitEventsNamespace.StrTokenNSPrefix('');

//Tags that need a little TLC to turn them into real links
List<String> emailTags = new List<String>{
'UG_Parking_Pass_Link__c',
'Add_To_Calendar_Link__c',
'Event_Registration_Cancel_Link__c',
'Add_to_Apple_Calendar__c',
'Add_To_Google_Calendar_Link__c',
'Add_to_Outlook_Calendar__c',
'Add_To_Outlook_Web_Calendar__c',
'Add_To_Yahoo_Calendar__c'
};

//Add the namespace to the email tags so that both namespaced and non-namespaced version work
if (String.isNotBlank(namespace)) {
List<String> emailTagsPackaged = new List<String>();
for (String tag : emailTags) {
emailTagsPackaged.add(namespace + tag);
}
emailTags.addAll(emailTagsPackaged);
}

//Delineator of content in the email templase
String originalTemplate = '[[DONT_DELETE_CONTENT_HERE]]';

Expand Down Expand Up @@ -155,12 +133,23 @@ public class SummitEventsRegistration {
found = '';
}

//replace all hooks with found values from registration
if (emailTags.contains(matcher2.group(1))) {
//Fix formula links that are encoded with the following format: _HL_ENCODED_[link URL]_HL__blank_HL_[link text]_HL_
if (found.startsWith('_HL_ENCODED_') && found.endsWith('_HL__blank_HL_')) {
found = found.replace('_HL_ENCODED_', '<a href="');
found = found.replace('_HL__blank_HL_', '</a>');
found = found.replace('_HL_', ' target="_blank">');
found = found.replace('%20target=', '');
found = found.replace(' target=', '');
found = found.replace('_HL_', '" target="_blank">');
}

//Fix any image links that are encoded with the following format: _IM1_[image source]_IM2_[alt text]_IM3_[height]_IM4_[width]_IM5_
if (found.startsWith('_IM1_') && found.endsWith('_IM5_')) {
found = found.replace('_IM1_', '<img src="');
found = found.replace('_IM2_', '" alt="');
found = found.replace('_IM3_', '" style="height:');
found = found.replace('_IM4_', 'px; width:');
found = found.replace('_IM5_', 'px;" border="0" ');
found += '/>';
}

emailContent = matcher2.replaceAll(found);
Expand Down Expand Up @@ -229,7 +218,7 @@ public class SummitEventsRegistration {
t.Description = emailMessage + '\n\n' + t.Description;
}
doCRUD crudToDo = new doCRUD();
crudToDo.savTask(activityUpdates);
crudToDo.saveTask(activityUpdates);
}
}

Expand Down Expand Up @@ -280,7 +269,7 @@ public class SummitEventsRegistration {

private without sharing class doCRUD {

public void savTask(List<Task> taskToSave) {
public void saveTask(List<Task> taskToSave) {
try {
insert taskToSave;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<Layout xmlns="http://soap.sforce.com/2006/04/metadata">
<layoutSections>
<customLabel>false</customLabel>
<detailHeading>false</detailHeading>
<editHeading>true</editHeading>
<label>Information</label>
<layoutColumns>
<layoutItems>
<behavior>Required</behavior>
<field>MasterLabel</field>
</layoutItems>
<layoutItems>
<behavior>Required</behavior>
<field>Source_Type__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>Source_Object__c</field>
</layoutItems>
<layoutItems>
<behavior>Required</behavior>
<field>Source_Value__c</field>
</layoutItems>
<layoutItems>
<behavior>Required</behavior>
<field>Person_Account_Field_API_Name__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
<behavior>Required</behavior>
<field>DeveloperName</field>
</layoutItems>
<layoutItems>
<behavior>Required</behavior>
<field>NamespacePrefix</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>IsProtected</field>
</layoutItems>
<layoutItems>
<behavior>Required</behavior>
<field>Person_Account_Matching_Method__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>Matching_Only__c</field>
</layoutItems>
</layoutColumns>
<style>TwoColumnsTopToBottom</style>
</layoutSections>
<layoutSections>
<customLabel>false</customLabel>
<detailHeading>false</detailHeading>
<editHeading>true</editHeading>
<label>System Information</label>
<layoutColumns>
<layoutItems>
<behavior>Readonly</behavior>
<field>CreatedById</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
<behavior>Readonly</behavior>
<field>LastModifiedById</field>
</layoutItems>
</layoutColumns>
<style>TwoColumnsTopToBottom</style>
</layoutSections>
<layoutSections>
<customLabel>true</customLabel>
<detailHeading>true</detailHeading>
<editHeading>false</editHeading>
<label>Custom Links</label>
<layoutColumns/>
<layoutColumns/>
<layoutColumns/>
<style>CustomLinks</style>
</layoutSections>
<showEmailCheckbox>false</showEmailCheckbox>
<showHighlightsPanel>false</showHighlightsPanel>
<showInteractionLogPanel>false</showInteractionLogPanel>
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox>
<showSubmitAndAttachButton>false</showSubmitAndAttachButton>
<summaryLayout>
<masterLabel>00hcf000004ENLz</masterLabel>
<sizeX>4</sizeX>
<sizeY>0</sizeY>
<summaryLayoutStyle>Default</summaryLayoutStyle>
</summaryLayout>
</Layout>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Layout xmlns="http://soap.sforce.com/2006/04/metadata">
<excludeButtons>OpenSlackRecordChannel</excludeButtons>
<excludeButtons>Submit</excludeButtons>
<layoutSections>
<customLabel>true</customLabel>
Expand Down Expand Up @@ -126,6 +127,10 @@
<behavior>Readonly</behavior>
<field>UG_Parking_Pass_Link__c</field>
</layoutItems>
<layoutItems>
<behavior>Readonly</behavior>
<field>Registrant_Id_QR_Code__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
Expand Down Expand Up @@ -806,7 +811,7 @@
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox>
<showSubmitAndAttachButton>false</showSubmitAndAttachButton>
<summaryLayout>
<masterLabel>00h6t000003YwxN</masterLabel>
<masterLabel>00hcf000004ENM1</masterLabel>
<sizeX>4</sizeX>
<sizeY>0</sizeY>
<summaryLayoutStyle>Default</summaryLayoutStyle>
Expand Down
Loading