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.BadgeService Class

FieloPLT.BadgeService Class includes two methods.

Obtain Badges (getBadgesMap)

static List<FieloPLT.BadgeService.BadgeWrapper> FieloPLT.BadgeService.getBadgesMap (Set<String> fieldsBadge, Set<String> fieldsBadgeMember, Set<String> fieldsRule, Set<String> fieldsChallengeReward, Set<Id> badgesIds, Id memberId, Boolean filterBySegments, String orderBy, Integer quantity, Integer offset, String dynamicFilter)

It allows obtaining a Badge map for a specific Member. It also enables you to identify which Badges Members have already obtained (either with Active or Expired status), those they can get (Achievable) and the ones they can't obtain (Lost or Not applicable).

📘

Badges statuses

Badges may have any of the following statuses when linked to a specific Member:

  • Active: Member has at least a Badge either without expiration date or whose expiration date is equal or greater than today.
  • Expired: Member has at least a Badge which has already expired.
  • Achievable: Member may obtain a Badge as they share same Segment and Program, and the Incentive (either a Promotion or Challenge) granting the Badge is Active.
  • Lost: Member can't obtain the Badge as the Incentive (either a Promotion or Challenge) granting the Badge is Inactive.
  • Not Applicable: Members can't obtain the Badge as they do not share the same Segment.

Parameters

ParameterTypeDescription
fieldsBadgeSet<String>Set of API Names from Badge fields to return in the response.
fieldsBadgeMemberSet<String>Set of API Names from Badge Member fields to return in the response.
fieldsRuleSet<String>Set of API Names from Rules fields to return in the response.
fieldsChallengeRewardSet<String>Set of API Names from Challenge Reward fields to return in the response.
badgesIdsSet<Id>Set of Badges IDs.
memberIdIdMember ID.
filterBySegmentsBooleanIt returns the Badges 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.BadgeService.BadgeWrapper>List of Badge Wrappers.
Id memberId = [SELECT Id FROM FieloPLT__Member__c LIMIT 1].Id;
String dynamicFilter = '[{"field":"FieloPLT__Status__c","value":"Active","operator":"eq","andOrOperator":""}]' 
List<FieloPLT.BadgeService.BadgeWrapper> result = FieloPLT.BadgeService.getBadgesMap(
  new Set<String>{'Id','Name'},
  new Set<String>{'Id'},
  new Set<String>{'Id','Name'},
  new Set<String>{'Id'},
  null,
  memberId,
  true,
  'CreatedDate ASC',
  100,
  0,
  dynamicFilter);

Expire Badges (setBadgeMemberExpirationDate)

static String FieloPLT.BadgeService.setBadgeMemberExpirationDate (Set<Id> memberIds)

It enables you to select all Badges from specific Members (represented in the object Badge Members). For Badges which have not expired yet, Badge Member Expiration is set on the date when the method is called (System Date).

Parameters

ParameterTypeDescription
memberIdsSet<Id>Set of Member IDs to expire their Badges.

Return Value

TypeDescription
StringBadges are expired successfully.

Exceptions

TypeDescription
FieloExceptionWhen Member ID is either invalid or empty.
Set<Id> memberIds = new Set<Id>();
for(FieloPLT__Member__c m : [Select Id from FieloPLT__Member__c]){
  memberIds.add(m.Id);
}

String result = FieloPLT.BadgesService.setBadgeMemberExpirationDate(memberIds);