HomeGuidesDeveloper HubRelease Notes
Get supportBook a chat
Developer Hub
These docs are for v2.76. Click to read the latest docs for v2.208.

FieloPLT.ContactRelationship Interface

Customize the relationship between Salesforce Contacts and Fielo Members

The FieloPLT.ContactRelationship interface includes one method.

Obtain related Salesforce Contacts (getRelatedContacts)

List<Contact> FieloPLT.ContactRelationship.getRelatedContacts (List<FieloPLT__Member__c> members)

It is an interface class that provides a logic for Salesforce Contact relationship. It lets you choose how to link your existing Salesforce Contacts with Members. Before creating the relationship, you need to add the class that implements the interface as follows:

  1. From Setup, go to Custom Settings by searching on the Quick Find search box.
  2. Choose Public Settings and click Manage> New.
  3. In Contact Relationship Class, write the class name and hit Save.

Parameters

ParameterTypeDescription
membersList<FieloPLT__Member__c>List of Members.

Return Value

TypeDescription
List<Contact>List of Salesforce Contacts linked to each Member.
❗️

Salesforce Contacts must match in number and order the entered Members, to keep the relationship between them.
If a Member does not find its corresponding related Salesforce Contact, its value is Null.

global class ContactRelationshipImplementation implements FieloPLT.ContactRelationship{ 
  global List<Contact> getRelatedContacts(List<FieloPLT__Member__c> members){
   for(FieloPLT__Member__c m : members){
     if(String.isNotBlank(m.FieloPLT__Email__c)) emails.add(m.FieloPLT__Email__c);   
   }       
   //Query contacts with Members' emails
   List<Contact> contacts = [SELECT Id, Email FROM Contact WHERE Email IN: emails];        
   Map<String, Contact> contactByEmail = new Map<String, Contact>();
   for(Contact c : contacts){
   	contactByEmail.put(c.Email, c);       
   }
   //Create the list of Contacts for Members
   for(Integer i = 0; i < members.size(); i++){
   	//If a Contact has the same email, add the corresponding Contact to the list  
     if(contactByEmail.containsKey(members[i].FieloPLT__Email__c)){       											
       result.add(contactByEmail.get(members[i].FieloPLT__Email__c));      
   	}else{       
     result.add(null);
    }
   } 
   return result;    
	}        
}