The FieloPLT.SegmentService class includes three methods.
Obtain Member Segments (getMemberSegments)
static Set<Id> FieloPLT.SegmentService.getMemberSegments (Id memberId, Set<Id>segmentIds)
Enables you to obtain information about Segments from a particular Member (Member Segments).
Parameters
| Parameter | Type | Description |
|---|---|---|
| memberId | Id | ID of a specific Member. |
| segmentIds | Set<Id> | Optional parameter that evaluates a set of Segments IDs. |
Return Value
| Type | Description |
|---|---|
Set<Id> | Set of Member IDs. |
Cookie storageThe first time the method is executed, it stores Segment values in your browser cookies. Unless Member ID and User session change, the API always returns the value stored in your browser cookies.
FieloPLT__Member__c member = [SELECT Id FROM FieloPLT__Member__c LIMIT 1];
Set<Id> segmentIds = FieloPLT.SegmentService.getMemberSegments(member.Id, null);Verify Segments (verifySegments)
static void FieloPLT.SegmentService.verifySegments (Map<Id,Set<Id>> segmentsByMember)
It enables you to obtain information about Segments from different Members.
Parameters
| Parameter | Type | Description |
|---|---|---|
| segmentsByMember | Map<Id,Set\<Id>> | IDs of Members from Segments to retrieve. The set of Segments IDs that apply for each Member are set as values. |
Return Value
| Type | Description |
|---|---|
| Void | Void. |
Map<Id, Set<Id>> segmentsByMember = new Map<Id, Set<Id>>();
Set<Id> segmentIds = new Set<Id>();
for(FieloPLT__Segment__c segment : [SELECT Id FROM FieloPLT__Segment__c LIMIT 5]){
segmentIds.add(segment.Id);
}
for(FieloPLT__Member__c member : [SELECT Id FROM FieloPLT__Member__c LIMIT 5]){
segmentsByMember.put(member.Id, segmentIds);
}
FieloPLT.SegmentService.verifySegments(segmentsByMember);Obtain Segments (getMetasegmentId)
static Id FieloPLT.SegmentService.getMetasegmentId (Set<Id> segmentIds)
It enables you to obtain information from any Segment, created in any object (either Salesforce standard or a custom object). Some Platform objects already include a relationship to Segments, such as Incentives and Rewards. If you need to relate Segments to other objects, you must previously create a relationship as established in Segments.
Parameters
| Parameter | Type | Description |
|---|---|---|
| segmentIds | Set<Id> | ID of Segments to retrieve. |
Return Value
| Type | Description |
|---|---|
| Id | Unique ID which comprises all individual Segment IDs. |
Set<Id> segmentIds = new Set<Id>();
for(FieloPLT__Segment__c segment : [SELECT Id FROM FieloPLT__Segment__c WHERE RecordType.DeveloperName != 'Metasegment' LIMIT 3]){
segmentIds.add(segment.Id);
}
Id metaSegmentId = FieloPLT.SegmentService.getMetaSegmentId(segmentIds);
WHERE ClauseIn order to obtain information about the Members which are included in a specific Segment, send the following query:
String whereClause = [SELECT FieloPLT__WHEREClause__c FROM FieloPLT__Segment__c LIMIT 1][0].FieloPLT__WHEREClause__c;
List<FieloPLT__Member__c> members = Database.query('SELECT Id, Name FROM FieloPLT__Member__c WHERE ' + whereClause);
Segment Criteria ValueSegment Criteria must include a static Value. Otherwise, if Criteria in Segments includes at least a ticked Field, Value becomes
{!FieldName}in the WHERE Clause. Salesforce does not allow direct field to field comparison in a SOQL query, so you must decide how to implement it.
E.g. If Segment Criteria defines that Segment must include Members whose Points are greater than Miles, its WHERE Clause must be FieloPLT__Points__c>{!Miles\_\_c}.
