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

FieloPLT.AgreementService Class

FieloPLT.AgreementService class includes two methods.

Obtain Current Agreement (getCurrentAgreement)

static FieloPLT__Agreement__c FieloPLT.AgreementService.getCurrentAgreement (Id programId, Set<String> fieldNames)

Agreement sets the terms and conditions that members need to accept in order to take part in a program. This API allows you to obtain the Agreement with status set as current that belongs to a specific program.

Parameters

Here you'll find an example of how the API can be used and a definition of it's parameters:

Id programId = [SELECT Id FROM FieloPLT__Program__c LIMIT 1].Id;

Set<String> fields = new Set<String>{'Id', 'FieloPLT__Status__c', 'FieloPLT__Agreement__c', 'FieloPLT__Promotion__c','FieloPLT__Challenge__c'};

FieloPLT__Agreement__c agreement = FieloPLT.AgreementService.getCurrentAgreement(programId, fields);
ParameterTypeDescriptionRequired
programIdIdID of the program the agreement is part of.x
fieldNamesSet<String>List of API names from agreement fields to query.x
fieldNames/ IdStringID of the active agreement linked to the program.
fieldNames/ FieloPLT__Status__cStringStatus of the agreement.
fieldNames/ FieloPLT__Agreement__cStringName of the agreement.

Return Values

Here you'll find an example of what is returned in the call and a definition of it's values:

FieloPLT__Agreement__c:{FieloPLT__Status__c=Current, FieloPLT__Agreement__c=TermsofService, Id=a020W00000Jp29XQAR}
ParameterTypeDescription
FieloPLT__Agreement__cSet<String>Current Agreement from the specific program.
FieloPLT__Agreement__c/ FieloPLT__Status__cStringStatus of the agreement.
FieloPLT__Agreement__c/ FieloPLT__Agreement__cStringName of the agreement.
FieloPLT__Agreement__c/ IdStringID of the active agreement linked to the program.

Exceptions

Errors can occur when you use the endpoint. Use the message description to troubleshoot them.

FieloPLT.FieloException: Program does not have a "Current" Agreement available.
TypeDescription
FieloExceptionNo agreement available. Make sure you have an available agreement.
FieloExceptionAgreement status is set to Draft. Make sure the agreement status is set to "Current".

Accept Agreement (acceptAgreement)

public static Boolean acceptAgreement(Id agreementId, Id memberId, Id recordId)

Use this API when you want your members to accept an agreement before registering to an specific program or before enrolling in a promotion or a challenge. It will relate a member with either a program agreement with the status set as current or an incentive agreement with the status set as current.

Parameters

ParameterTypeDescription
agreementIdIdID of the Agreement. You can get this information using the the previously mentioned API Obtain Agreement (getCurrentAgreement).
memberIdIdMember ID.
recordIdIdID of the record, such as a program id, a promotion id or a challenge id.

Return Value

TypeDescription
try{
            Boolean agreed = true;
            if(agreementId != null) {
                agreed = AgreementService.acceptAgreement(agreementId, memberId, recordId);
            }

            if(agreed && type == 'challenge') {
                ChallengeMember__c challengeMember = 
                    FieloPLT.ChallengeService.subscribeToChallenge(memberId, incentiveId);
            }

           return true;
        } catch(DMLException e) {
            throw new AuraHandledException(e.getDMLMessage(0));
        } catch(Exception e){
            throw new AuraHandledException(e.getMessage());
        }