HomeGuidesDeveloper HubRelease Notes
Get supportBook a chat
Guides

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.

📘

Example

A 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):

FieldAPI NameTypeDescription
DeductedFieloPLT__Deducted__cCheckboxWhen 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 PointsFieloPLT__DeductedPoints__cDecimalNumber 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):

FieldAPI NameTypeDescription
Async Use PointsFieloPLT__AsyncUsePoints__cIntegerWhen On, all negative points will be processed (consume the positive points) exclusively by the batch UsePointsBatchSchedule or queueable class UsePointsQueueable.
Use Points LimitFieloPLT__UsePointsLimit__cIntegerControls 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 ChainFieloPLT__UsePointsMaxChain__cIntegerControls how many times the UsePointsBatchSchedule or UsePointsQueueable classes can auto call itself
Use Points Process All RecordsFieloPLT__UsePointsAllRecords__cCheckboxWhen 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 QueueableFieloPLT__UsePointsQueueable__cCheckboxWhen 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 ErrorFieloPLT__UsePointsThrowError__cCheckboxWhen 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 FieldFieloPLT__MemberAutoNumberField__cTextName of the autonumber custom field to be used to split member processes in threads
Use Points Queueable Query LimitFieloPLT__UsePointsQueueableLimit__cIntegerControls the number of positive point records that will be marked as used by the use points engine.
Use Points ThreadsFieloPLT__UsePointsThreads__cIntegerWhen 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 Apex batch

Use Points Async


Did this page help you?