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

Challenge Rank

Ranks can be a great way to provide perks to members that reach a specific rank. For example, if the member reaches the Gold rank, they can gain access to exclusive products that only Gold members have access to. In order to do something like that - to define what is the outcome when a member ranks up - you would need to create your own custom action. For that, follow the steps below:

Create Apex Class

In your Org, go to Setup and search for Apex Classes in the Quick Find box. Click New to add your class.

global with sharing class CustomActionSample implements FieloPLT.ChallengeLevel{

    global void promoteRank(List<FieloPLT__ChallengeMember__c> challengeMembers){
        System.debug('Promote '+ challengeMembers);

        Set<Id> levelMemberIds = new Set<Id>();
        for(FieloPLT__ChallengeMember__c chm : challengeMembers){
            if( chm.FieloPLT__LevelMember__c != null ){
                levelMemberIds.add(chm.FieloPLT__LevelMember__c);
            }
        }

        if( !levelMemberIds.isEmpty() ){
            Map<Id, FieloPLT__LevelMember__c> levelMembersMap = new Map<Id, FieloPLT__LevelMember__c>([Select Id, FieloPLT__Level__r.Name, FieloPLT__Member__c FROM FieloPLT__LevelMember__c Where Id In: levelMemberIds]);
            for(FieloPLT__ChallengeMember__c chm : challengeMembers){
                if( chm.FieloPLT__LevelMember__c != null ){
                    System.debug('It was given the Level '+levelMembersMap.get(chm.FieloPLT__LevelMember__c).FieloPLT__Level__r.Name);

		// Your business logic should be added here
                }
            } 
        }
    }
}

Once the class has been created, you’ll need to add it as one of the options of the page.

Adding the custom action to the rank page

Still on Setup, click on the Object Manager tab and look for Level.

On the right menu, click on Fields and Relationships and look for CustomAction. Add your recently created Method Name as a new value for the picklist.

Note that, in order to see the custom action section, the admin must create the Apex class.