Asynchronous Points Usage
Use Points at scale
Some large programs may issue many tiny point amounts (like 1 point or less per record) and members may redeem a large number of points at once. That can lead to a massive Point record update that Salesforce may not support in a single Apex transaction.
ExampleA program tends to reward points in very small increments, such that Point records average 0.5 points each. A member redeems 10,000 points. That would lead to a DML operation on 20,000 records, which would throw a platform exception. (On Salesforce, it is only possible to update up to 10,000 records per Apex transaction.)
Based on a member's balance, Fielo's Use Points process will determine whether the redemption or negative accrual and the points update (update of the FieloPLT__UsedPoints__c field) should be done asynchronously:
- If we are able to retrieve all required Point records from the database and mark each of them as used (i.e. FieloPLT__UsedPoints__c = something), then this is done in real time and no further processing is needed.
- If we are NOT able to retrieve all required Point records from the database and mark them as used (i.e. FieloPLT__UsedPoints__c = something), usually because we could not fetch all required points to use or because the update risks exceeding Salesforce governor limits, then Use Points will flip to asynchronous mode.
There are two new fields on the Point object that apply only to point deductions (redemptions / negative accruals / negative adjustments):
| Field | API Name | Type | Description |
|---|---|---|---|
| Deducted | FieloPLT__Deducted__c | Checkbox | When N, it means the negative point record was not entirely deducted of the member credits, When Y or NULL Total Points should be the same as Deducted Points. |
| Deducted Points | FieloPLT__DeductedPoints__c | Decimal | Number of points that were successfully deducted from the member credits |
Feature Management
To enable Async Usage OR to control the real-time consumption of positive Point records, Fielo now has the following fields in Public Settings (Salesforce Setup > Custom Settings > Public Settings):
| Field | API Name | Type | Description |
|---|---|---|---|
| Async Use Points | FieloPLT__AsyncUsePoints__c | Integer | When On, all negative points will be processed (consume the positive points) exclusively by the batch UsePointsBatchSchedule or queueable class UsePointsQueueable. |
| Use Points Limit | FieloPLT__UsePointsLimit__c | Integer | Controls how many positive points will be consumed each time a negative point gets processed. The remaining points will be processed by the Batch UsePointsBatchSchedule or Queueable class UsePointsQueueable |
| Use Points Max Chain | FieloPLT__UsePointsMaxChain__c | Integer | Controls how many times the UsePointsBatchSchedule or UsePointsQueueable classes can auto call itself |
| Use Points Process All Records | FieloPLT__UsePointsAllRecords__c | Checkbox | When On, the async processing (UsePointsBatchSchedule or UsePointsQueueable) will ignore the Max Chain parameter and will call itself again until all negative points to be deducted are entirely processed. |
| Use Points Queueable | FieloPLT__UsePointsQueueable__c | Checkbox | When enabled, the asynchronous processing of negative points will be performed by the UsePointsQueueable class. If disabled, the UsePointsBatchSchedule class will handle the processing. |
| Use Points Throw Error | FieloPLT__UsePointsThrowError__c | Checkbox | When set to true, the async use points process will throw an exception whenever it finds an issue; otherwise, it will save it to the ErrorLog. |
| Member Auto-Number Field | FieloPLT__MemberAutoNumberField__c | Text | Name of the autonumber custom field to be used to split member processes in threads |
| Use Points Queueable Query Limit | FieloPLT__UsePointsQueueableLimit__c | Integer | Controls the number of positive point records that will be marked as used by the use points engine. |
| Use Points Threads | FieloPLT__UsePointsThreads__c | Integer | When set and greater than zero, the async usage will be splitted into N threads to process all negative point records. |
Async Use Points Process
The Apex batch UsePointsBatchSchedule (or the queueable UsePointsQueueable) processes negative Point records that were marked as not yet deducted (FieloPLT__Point__c.FieloPLT__Deducted__c = 'N'). For Points that were only partially deducted, the amount that was deducted can be tracked in the field FieloPLT__Point__c.FieloPLT__DeductedPoints__c.
The batch can be executed on demand on the Fielo Batch Jobs page. Look for:

Use Points Async
Updated about 1 year ago
