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.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> fieldsRank, Set<String> fieldsChReward, Set<String> fieldsMissionMember, Set<String> fieldsChMember, Set<String> fieldsTransaction, Set<Id> challengeIds, Id memberId, String setName, String orderBy, String orderByMemberActivity, Integer quantity, Integer offset, String dynamicFilter, Boolean translate)

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 setName

The set name controls which set of challenges will be returned (these are case sensitive):

  • MyChallenges: It returns all the challenges which the member is participating in (exists challenge member, challenge member status can be any).

  • Apply: It returns all challenges that the member can participate in, meaning they are not subscribed yet and the member belongs to the incentive segmentation. The challenge status can be either Active, Edited, or Scheduled, and the subscription must be either Open or Global.

  • Not Apply: It returns all challenges where the member cannot participate (doesn’t exist ChallengeMember), meaning they are not subscribed yet and don't belong to the challenge segmentation. The challenge status can be either Active, Edited, or Scheduled and the subscription must be either Open or Global.

  • All Available: The aggregation of Apply and Not Apply. It returns all the challenges that the member can and cannot participate in regardless of segmentation. It will also return only the challenges that the Member is not enrolled in.

  • Active: It returns all Active challenges which the member is participating in (ChallegeMember exists and challengeMember status is not accomplished) and also the ones in which the member belongs to the segmentation and the subscription is global.

  • Open: It returns all the Active or Edited challenges which the member can participate in, meaning that they belong to the incentive segmentation, and it has the Private or Open (Opt-in) subscription mode.

  • Completed: It returns both challenges completed by the member, which the challengeMember status is equal to Accomplished, or finished challenges, which Challenge status is equal to Completed.

  • Lost: It returns all challenges that the member could have participated in, as they belonged to the challenge’s segment, but they didn’t, meaning ChallengeMember doesn’t exist, and now the challenge Status is equal to completed.

  • Not Applicable: It returns all Active and Edited challenges which the member cannot participate in, as the member doesn't belong to the challenge’s segment. It doesn't matter the subscription mode the challenge is using.

  • Apply By Segmentation: It returns all Challenges that share the Member's Segmentation listed and those that the Member is already enrolled in.

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.
fieldsRankSet<String>Returns each Challenge’s rank. If inactive, nothing will be returned.
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.
setNameStringChallenge status to filter values in the response (Values may be: MyChallenges, Apply, Not Apply, All Available, Active, Open, Completed, Lost , Not Applicable and Apply By Segmentation).
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.
orderByMemberActivityStringRecords returned sorted by either the member's most recent activities or the oldest ones.
dynamicFilterStringJSON parameter to filter by an additional WHERE Clause. Divided by the type, e.g. <"promotion", dynamicFilter>. When null or empty, no filter is applied. If null, calculateMissionsProgress must be false. It shouldn't be used to filter the incentive by status. The status is defined by the setName.
translateBooleanIf this parameter is set to true, it fetches the available translation and changes the language of the component according to the member’s Salesforce user language, while if false, it’ll return the components in the default language.

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;
  }

Obtain Challenges (getChallengesMap)

  • Check below an example of how the API can be used:
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. Divided by the type, e.g. <"promotion", dynamicFilter>. When null or empty, no filter is applied. If null, calculateMissionsProgress must be false. It shouldn't be used to filter the incentive by status. The status is defined by the setName.

Return Value

🚧

Challenge Leaderboard Batch

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

TypeDescription
List<FieloPLT__MissionMember__c>List of Mission Members. If the Challenge Leaderboard batch job is not run, it returns value is either NULL or empty.

Obtain Mission Leaderboard (getMissionLeaderboard)

  • Check below an example of how the API can be used:
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);