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

FieloPLT.RegistrationAPI Class

Generally used for the Join Program component and to customize the registration, the FieloPLT.RegistrationAPI Class includes two methods.

Join Program (joinProgram)

List<FieloPLT__Member__c> FieloPLT.RegistrationAPI.joinPrograms(Set<Id> programIds)

This method will register an existing user - the one logged into your portal at the time - to a specific list of programs in your org. With this, you can make it possible for any users that are not members yet, to join one or more new programs that exist in your org.

Take a look at a step by step guide on how to use this method.

Parameters

Check an example of how the API can be used below and a definition of its parameters right after:

//Get programs to which enroll the user in
Map<Id, FieloPLT__Program__c> programs = new Map<Id, FieloPLT__Program__c>([SELECT Id FROM FieloPLT__Program__c]);
                   
//Call RegistrationAPI.joinPrograms, passing a set of program Ids
List<FieloPLT__Member__c> members = FieloPLT.RegistrationAPI.joinPrograms(programs.keySet());
ParametersTypeDescriptionRequired
programIdsSet<Id>A set of program IDs, which will identify the programs that the member will join.Yes

Return Value

Take a look below at an example of what is returned in the call and a definition of the return values right after:

(
	List<FieloPLT__Member__c>: {
		FieloPLT__Member__c: [Name=John Doe, [email protected], FieloPLT__Program__c=a0p1h000001T1gnAAC, User__c=0058A0000070YK4QAM, FieloPLT__Type__c=Individual Account, FieloPLT__Agreement__c=null],
		FieloPLT__Member__c: [Name=John Doe, [email protected], FieloPLT__Program__c=a0p8A000002FjdqQAC, User__c=0058A0000070YK4QAM, FieloPLT__Type__c=Individual Account, FieloPLT__Agreement__c=a028A000004SfflQAC]
	}
)
TypeDescription
List<FieloPLT__Member__c>List of members that were created in the program(s), related to the current user.

Exception

Errors can occur when you use the endpoint. See below the exception that you can receive when using the joinProgram:

TypeDescription
FieloApiException
  • Parameter {programIds} is necessary.* When Program ID is either invalid or empty.

Member Registration (selfRegister)

selfRegister actually has two overloads. The first one is:
FieloPLT__Member__c RegistrationAPI.selfRegister(Map<String, Map<String, Object>> fieldsetsMap, String password, Map<Id, Boolean> consents)

The second overload is:
FieloPLT__Member__c RegistrationAPI.selfRegister(Map<String, Map<String, Object>> fieldsetsMap, String password, Map<Id, Boolean> consents, Id accountId)

Use this method whenever you want to enable new people to register in your site and program: it will create a Salesforce user and a program member for them. Note that the program in which they will be registered is the default one, selected previously in the component or defined through the Map.

The difference between both overloads is that the first one will associate the Account defined previously (during the site configuration) with the new member, while the second overload allows you to override the configuration and define another Account to be associated with the member.

Take a look at a step by step guide on how to use this method.

Parameters

Check an example of how the API can be used below and a definition of its parameters right after:

//Create user fieldset map
Map<String, Object> userFields = new Map<String, Object>();
userFields.put('FirstName', 'John');
userFields.put('LastName', 'Doe');
userFields.put('Email', '[email protected]');

//Get program Id in which the member will be enrolled in
Id programId = [SELECT Id FROM FieloPLT__Program__c LIMIT 1].Id;

//Create member fieldset map
Map<String, Object> memberFields = new Map<String, Object>();
memberFields.put('Name', 'John Doe');
memberFields.put('FieloPLT__Email__c', '[email protected]');
memberFields.put('FieloPLT__Program__c', programId);

//Create fieldsetsMap to be passed to the API
Map<String, Map<String, Object>> fieldsetsMap = new Map<String, Map<String, Object>>();
fieldsetsMap.put('user', userFields);
fieldsetsMap.put('member', memberFields);

String password = 'SuP3rS3cur3**';

//Get consents and set user input
List<FieloPLT__Consent__c> consentsList = [SELECT Id FROM FieloPLT__Consent__c];
Map<Id, Boolean> consents = new Map<Id, Boolean>();
for(FieloPLT__Consent__c c : consentsList){
    consents.put(c.Id, true);
}

//Call RegistrationAPI.selfRegister to create the user and member
FieloPLT.RegistrationAPI.selfRegister(fieldsetsMap, password, consents);
ParametersTypeDescriptionRequired
fieldsetsMapMap<String, Map<String, Object>>This is a Map that contains the values for the User and Member Objects field that are going to be created. Any field that exists on the objects is available to be an input. E.g. Name, Type__c, Points__c.Yes
passwordStringThe user's password.No
consentsMap<Id, Boolean>A map containing the consent ID and the user's response.No
accountIdIdSpecifies the ID of the Account that will be associated with the new member.Yes (for the second overload of the method)

The fieldsetMap parameter has a mandatory minimum expected input:

{
	"member":{
		"Name": "memberName",
		"FieloPLT__Email__C": "memberEmail",
		"FieloPLT__Program__c": "memberProgram"
	},
	"user":{
		"FirstName": "userFirstName",
		"LastName": "userLastName",
		"Email": "userEmail"
	}
}

//`member.FieloPLT__Email__c` and `user.Email` should be the same.

Errors

This method doesn't have a return, but errors can occur when you use the endpoint. Find below a the most common error messages that you can receive from FieloApiException type.

Error MessageReason
Parameter {fieldsetMap} is necessary.The input fieldsetMap is either null or empty.
Parameter {fieldsetMap.member} is necessary.The input fieldsetMap doesn't have a key "member".
Parameter {fieldsetMap.user} is necessary.The input fieldsetMap doesn't have a key "user".
Fieldset does not contain mandatory field: {member.Name}The input fieldsetMap.member doesn't have a key "Name"
  • Fieldset does not contain mandatory field: 
    {member.FieloPLT__Email__c}*
The input fieldsetMap.member doesn't have a key "FieloPLT__Email__c"
  • Fieldset does not contain mandatory field: 
    {member.FieloPLT__Program__c}*
The input fieldsetMap.member doesn't have a key "FieloPLT__Program__c"
  • Fieldset does not contain mandatory field: 
    FIRSTNAME*
The input fieldsetMap.user doesn't have a key "FirstName"
  • Fieldset does not contain mandatory field: 
    LASTNAME*
The input fieldsetMap.user doesn't have a key "LastName"
  • Fieldset does not contain mandatory field: 
    EMAIL*
The input fieldsetMap.user doesn't have a key "Email"
  • Fieldset values are different:
    {FieloPLT__Email__c (member fieldset)}, {Email (user fieldset)}*
The input fieldsetMap.member.FieloPLT__Email__c and fieldsetMap.user.Email do not match.
  • An Individual Member already exists for that 
    Salesforce Contact in this Program.*
A member that already exists in the program has the email provided.

Exception

Errors can occur when you use the endpoint. See below the exception that you can receive when using the selfRegister:

TypeDescription
FieloApiException
  • Parameter {fieldsetMap} is necessary.* When fieldsetMap is either invalid or empty.