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

FieloPLT.ChallengeService Class

FieloPLT.ChallengeService class includes one method.

Obtain Challenges (getChallengesMap)

static List<FieloPLT.ChallengeService.ChallengeWrapper> FieloPLT.ChallengeService.getChallengesMap (Set<String> fieldsChallenge, Set<String> fieldsMission, Set<String> fieldsChReward, Set<String> fieldsMissionMember, Set<String> fieldsChMember, Set<String> fieldsTransaction, Set<Id> challengeIds, Id memberId, String status, Boolean filterBySegments, String orderBy, Integer quantity, Integer offset, String dynamicFilter)

It allows you to retrieve information about a number of Challenges map from a particular Member. It can also provide details about the Missions, Challenge Rewards, Challenge Members, Mission Members and Transactions linked to a Challenge.

Members are considered subscribed to a Challenge when Members and Challenge share the same Segment and Subscription Mode is Global. When Subscription Mode is Closed, Members are considered subscribed by means of a Challenge Member record.

📘

Challenges status

Challenges may have any of the following status when linked to a specific Member:

  • Active: Member is subscribed to a Challenge with status Active. Challenge Member status must not be Accomplished (E.g. Member has "My Challenges" section).
  • Completed: Member is subscribed to a Challenge with status Completed, or to a Challenge with status Active but the Challenge Member status must be Accomplished.
  • Open: Members may be subscribed to the Challenge as they share the same Segment. Challenge is Active and its Subscription mode must be Closed.
  • Lost: Member may be subscribed to the Challenge as they share the same Segment. Challenge is not Active and its Subscription mode must be Closed.
  • Not Applicable: Although Challenge is Active, Members are not subscribed as they do not share the same Segment.

Parameters

ParameterTypeDescription
fieldsChallengeSet<String>Set of API Names from Challenge fields to return in the response.
fieldsMissionSet<String>Set of API Names from Mission fields to return in the response.
fieldsChRewardSet<String>Set of API Names from Challenge Reward fields to return in the response.
fieldsMissionMemberSet<String>Set of API Names from Mission Member fields to return in the response.
fieldsChMemberSet<String>Set of API Names from Challenge Member fields to return in the response.
fieldsTransactionSet<String>Set of API Names from Transaction fields to return in the response.
challengeIdsSet<Id>Set of Challenge IDs.
memberIdIdID of a specific Member.
statusStringChallenge status to filter values in the response (Values may be: Active, Completed, Open, Lost and Not Applicable).
filterBySegmentsBooleanIt returns the Challenges that belong to Member's Segment.
quantityIntegerNumber of items to be retrieved. When NULL, query return all items.
offsetIntegerNumber of records from a collection to skip. When null, no records are skipped.
orderByStringRecords returned in an ascending or descending order.
dynamicFilterStringJSON parameter to filter by an additional WHERE Clause. When null, no filter is applied.

Return Value

TypeDescription
List<FieloPLT.ChallengeService.ChallengeWrapper>List of Challenge Wrappers. Challenge Wrappers include the following attributes:
Class FieloPLT.ChallengeWrapper{
	FieloPLT__Challenge__c challenge;
	String status;
  FieloPLT__ChallengeMember__c challengeMember;
	List<FieloPLT__Mission__c> missions;
  List<FieloPLT__ChallengeReward__c> challengeRewards;
  Map<Id,List<FieloPLT__ChallengeReward__c>> missionRewards;
  Map<Id,FieloPLT__MissionMember__c> missionsMember;
  List<FieloPLT__Transaction__c> transactions;
  }
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;

String dynamicFilter = '[{"field":"FieloPLT__Status__c","value":"Active","operator":"eq","andOrOperator":""}]';

List<FieloPLT.ChallengeService.ChallengeWrapper> result = FieloPLT.ChallengeService.getChallengesMap(
  new Set<String>{'Name'},
  new Set<String>{'Name'},
  new Set<String>{'Name'},
  null,
  null,
  null,
  null,
  memberId,
  null,
  true,
  'CreatedDate ASC',
  100,
  0,
  dynamicFilter);

Obtain Mission Leaderboard (getMissionLeaderboard)

static List<FieloPLT__MissionMember__c> getMissionLeaderboard (Set<String> fieldsMissionMember, Id missionId, Id memberId, String orderBy, Integer quantity, Integer offset, String dynamicFilter)

It enables you to retrieve information about Member rankings in a Leaderboard of a specific Mission, which is stored in Mission Member records. You can also obtain information about how a particular Member has performed on the Leaderboard.

ParameterTypeDescription
fieldsMissionMemberSet<String>Set of API Names from Mission Member fields to return in the response.
challengeIdsSet<Id>Set of Challenge IDs.
memberIdIdID of a specific Member.
quantityIntegerNumber of items to be retrieved. When NULL, query return all items.
offsetIntegerNumber of records from a collection to skip. When null, no records are skipped.
orderByStringRecords returned in an ascending or descending order.
dynamicFilterStringJSON parameter to filter by an additional WHERE Clause. When NULL, no filter is applied.

Return Value

🚧

Challenge Leaderboard Batch

You must run Challenge Leaderboard batch job before calling Obtain Mission Leaderboard method.

TypeDescription
List<FieloPLTMissionMemberc>List of Mission Members. If the Challenge Leaderboard batch job is not run, it returns value is either NULL or empty.
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
Id missionId = [SELECT Id FROM FieloPLT__Mission__c LIMIT 1].Id;

String dynamicFilter = '[{"field":"FieloPLT__Status__c","value":"Accomplished","operator":"eq","andOrOperator":""}]';

List<FieloPLT__MissionMember__c> FieloPLT.ChallengeService.getMissionLeaderboard(new Set<String>{'Name'}, 
                    missionId,
                    memberId,
                    'CreatedDate ASC',
                    100,
                    0,
                    dynamicFilter);