Skip to content

Rule Action Reference

The Rule Action Reference explains the types of Engine Actions available for use within RCX Rules.

Member Management

Lookup Member

Lookup Member

This action looks up and populates member details for the current activity. Also, because resolving the member is usually the first action taken, checks for duplicate transactions by external transaction ID (activity.externalTxnId)

Parameters

None. Uses the current activity context.

JavaScript API

UDF.populateMember(callback)

Outputs

Populates Context with:

  • member: The member object
  • member.loyaltyIds: Array of loyalty IDs associated with the member
  • activity.memberID: ID of the member
  • activity.originalMemberID: Original member ID before any merges
  • autoEnroll: Boolean indicating if member was autoenrolled

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2002 Could not find member with member id %s Member ID not found in database
2038 Could not find member with loyalty id %s Member not found with given loyalty ID
2063 Duplicate activity with external transaction id %s Activity with same external transaction ID already exists

Additional Considerations

  • Lookup sequence:
    • Tries to find member by memberID
    • If not found, tries to find by loyaltyID
    • If still not found and program autoEnroll setting exists, autoenrolls the member
  • Supports autoenrollment into programs based on settings
  • Updates the member structure version if needed (if new purses have been added, and so on)
  • Handles member merges by resolving to survivor member if the activity was invoked with ?resolveMerge=true
  • Validates that the member program matches activity program
  • Checks for duplicate transactions by external transaction ID
Lookup Account Members

Lookup Account Members

This action looks up and populates all members linked to the current member's account. Only returns members from the same program.

Parameters

None. Uses the current member context.

JavaScript API

UDF.populateAccountMembers(callback)

Outputs

Populates Context.linkedAccount with:

  • members: Array of linked member objects from the same program
  • _id: Account ID
  • org: Organization ID
  • activeMember: ID of the active member in the account

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Only returns members from the same program as the current member
  • Automatically updates member structure version if needed
  • Marks transitive properties on purse accruals, redemptions and escrows
  • Returns empty members array if member has no linked account
  • Populates full member details excluding:
    • events
    • activities
    • rewards
    • offers
    • segments
    • badges
    • memberSegments
    • preferences
    • pendingIds
Lookup Member Aggregates

Lookup Member Aggregates

This action looks up and populates aggregate metrics for the member across different time periods.

Parameters

Parameter Type Format Description
Aggregates String/Array Text Names of aggregates to lookup
Aggregate Types String/Array Text Optional. Types of aggregates (daily, weekly, monthly, and so on)
From Date Date Text Optional. Start date for aggregate lookup
To Date Date Text Optional. End date for aggregate lookup

JavaScript API

UDF.populateMemberAggregates(aggregates, types, fromDate, toDate, callback)

Outputs

Populates Context with aggregate data in:

  • context[type + 'Aggs'] for each requested type (such as dailyAggs, weeklyAggs, and so on)

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
4033 Aggregates should be a string or array in Lookup Member Aggregates action Invalid aggregates parameter format
4033 Aggregate Types should be a string or array in Lookup Member Aggregates action Invalid types parameter format
4037 The date is not within the allowed range of 1900 to 3999 Invalid date range
4011 From Date should be less than or equal to current date in Lookup Member Aggregates action From date is in the future
4011 To Date should be greater than or equal to current date in Lookup Member Aggregates action To date is in the past

Additional Considerations

  • Supports multiple aggregate types: daily, weekly, monthly, quarterly, halfyearly, yearly, lifetime
  • Validates date ranges against the current activity date
  • Returns empty results if no aggregates are found
  • All dates are adjusted for timezone offset from the program settings (default time zone)
Update Member Aggregate

Update Member Aggregate

This action updates a member's aggregate value for a given policy.

Parameters

Parameter Type Format Description
Policy ID String Text The ID of the aggregate policy to update or 'Variable' for custom aggregates
Aggregate Name String Text The name of the aggregate (required if policyId is 'Variable')
Value Number Text The value to add to the aggregate
Aggregate Date Date Text The date to associate with the aggregate update
Expiration Date Date Text The expiration date for the aggregate

JavaScript API

There is no JS API for this action.

Outputs

Updates member's aggregate values in Context.aggregates.

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
9999 Balance should be a number in Update Member Aggregate action Value parameter must be numeric
9999 Aggregate name is required when using Variable policy ID Aggregate name missing for Variable policy
2108 Aggregate policy with name %s not found The specified aggregate policy was not found
2109 Aggregate cannot be updated as policy %s is not effective The aggregate policy isn't yet in effect
2110 Aggregate Policy %s has already expired on %s The aggregate policy has expired

Additional Considerations

  • Validates the numeric parameters (value)
  • Filters policies by:
    • Available redemptions > 0
    • Expiration date >= activity date
    • Budget > 0 for offers
    • Cost <= balance (if balance provided)
  • Applies location overrides if configured
  • Calculates maximum possible discount for each policy
  • Sorts results by discount amount (descending)
  • Returns top N results if maxPolicies specified
  • Handles both rewards and offers with budget constraints
Lookup Member Loyalty IDs

Lookup Member Loyalty IDs

This action looks up and populates loyalty IDs associated with the current member.

Parameters

None. Uses the current member context.

JavaScript API

There is no JS API for this action.

Outputs

Populates Context.member.loyaltyIds with an array of loyalty ID objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Returns early if no member is found in the context
  • Returns an empty array if no loyalty IDs are found
Lookup Merge Victims

Lookup Merge Victims

This action finds all members that were merged into the current member (victims of merge operations).

Parameters

Parameter Type Format Description
Member IDs String/Array Text Optional. Specific member IDs to lookup. If not provided, returns all merge victims

JavaScript API

UDF.populateMergeVictims(memberIds, callback)

Outputs

Populates Context.mergeVictim.members with an array of victim member objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Returns early if no context member is found (logs warning)
  • If memberIds is provided, validates that each ID is a valid ObjectId
  • Queries the mergetrail collection for victim records
  • Excludes transient fields from victim member objects
  • Returns silently if no merge victims are found

Points & Purses

Add Points

Add Points

This action accrues points to a Purse, usually to reward some Activity posted for the member. The action allows setting the Purse, points expiration date, escrow date and specifying the accounting type of the points. This is both a rule action and a user-defined function (UDF).

Parameters

Parameter Type Format Description
Purse Name String Dropdown Select the purse you want to use. If you want the purse name to be variable based on a calculated field, choose the Variable in this drop down and fill in the Purse Name field that appears next to the dropdown.
Points Number Integer Number of points to add. Must be a positive, whole number.
Accounting Type String Normal/Non-Revenue Categorizes the earn. Typically non-revenue earn is given for non-purchase activities.
Expiration Date Date/Time JS Date Expiration date for points. Defaults to Purse Policy setting.
Escrow Date Date/Time JS Date Escrow date for points. Defaults to Purse Policy setting.

Outputs

None

JavaScript API

UDF.addPoints(policyId, purseName, points, accountingType, expirationDate, escrowDate, cb)

Events Triggered

Generates the L2 AddPointsEvent when points are added.

Possible Errors

Error Code Error Message Description
2018 Purse is not found Purse not found
2020 Transfer of points between purses has failed Points transfer failed
2040 Can not find purse in member with _id %s Reported if the purse name is invalid
2052 The points to be added to purse %s are invalid Reported if points value is invalid
2070 Accrual expiry failed When expiry operation fails
2084 Accrual escrow failed When escrow operation fails
2131 Please provide valid expiration date Invalid expiration date
2132 Please provide valid escrow date Invalid escrow date
2147 Expiration date must be after the escrow date Expiration before escrow

Additional Considerations

  • In the Rule Builder the Purse Name is a drop-down, showing all the Purse Policies. You can select Variable if you would like to compute the Purse Name parameter at run-time.
  • If points is 0, the operation is skipped
  • Points can't be negative
  • If the rule has countLimit or budget > 0, the rule context is updated
  • To model floating point values (such as USD), use the lowest granularity (such as cents)
Redeem Points

Redeem Points

This action redeems points from a member's purse. The action validates available balance before redemption and handles locked points appropriately.

Parameters

Parameter Type Format Description
Purse Name String Dropdown Select the purse you want to use. If you want the purse name to be variable based on a calculated field, choose the Variable in this drop down and fill in the Purse Name field that appears next to the dropdown.
Points Number Integer Number of points to redeem. Must be positive, whole number.

JavaScript API

UDF.redeemPoints(policyId, purseName, points, cb)

Events Triggered

Generates the L2 RedeemPointsEvent when points are redeemed.

Possible Errors

Error Code Error Message Description
2040 Can not find purse in member with _id %s Reported if the purse name is invalid
2043 Failed to redeem %d points from purse %s because it has only %d points available When there are insufficient points
2053 The points to be redeemed from purse %s are invalid When points value is invalid
1762 Transaction cannot update members When transaction fails to update members

Additional Considerations

  • In the Rule Builder, the Purse Name is a drop-down, showing all the Purse Policies. You can select Variable to compute the Purse Name parameter at run-time.
  • If points is 0, the operation is skipped
  • Points can't be negative
  • Checks for the available balance before redeeming
  • Considers locked points when calculating the available balance
  • To model floating point values (such as USD), use the lowest granularity (such as cents)
Linked Add Points

Linked Add Points

This action adds points to multiple linked members' purses in a single operation. Points can be added with different amounts for each member, with optional accounting type, expiration date, and escrow date.

Parameters

Parameter Type Format Description
Purse Name String Dropdown Select the purse you want to use. If you want the purse name to be variable based on a calculated field, choose the Variable in this drop down and fill in the Purse Name field that appears next to the dropdown.
Points Array/Number Array of Objects or Integer Either a single points value for context member, or array of objects mapping member IDs to points and activities.
AccountingType String Normal/Non-Revenue Categorizes the earn - typically non-revenue earn is given for non-purchase activities.
Expiration Date Date/Time JS Date Expiration date for points. Defaults to Purse Policy setting.
Escrow Date Date/Time JS Date Escrow date for points. Defaults to Purse Policy setting.

Outputs

Returns array of updated purses.

JavaScript API

There is no JS API for this action.

Events Triggered

Generates the L2 AddPointsEvent for each member involved.

Possible Errors

Error Code Error Message Description
2040 Can not find purse in member with _id %s Reported if the purse name is invalid
2052 The points to be added to purse %s are invalid Reported if the points value is invalid
2084 Accrual escrow failed When the escrow operation fails
2070 Accrual expiry failed When the expiry operation fails
2091 Linked member with id %s not found to add points When the specified linked member isn't found
1807 Please provide activity in options of LinkedAddPoints action When the activity is missing for the linked member

Additional Considerations

  • In the Rule Builder the Purse Name is a drop-down, showing all the Purse Policies. You can select Variable if you would like to compute the Purse Name parameter at run-time.
  • If points is 0, operation is skipped
  • Points can't be negative
  • If rule has countLimit or budget > 0, rule context is updated
  • When using array format, each object must have:
  • memberId as key
  • amount: points to add
  • activity: activity object for the linked member
  • For single member operations, points can be a simple number
  • To model floating point values (such as USD), use the lowest granularity (such as cents)
  • Activities are automatically created and added to linked members
Linked Redeem Points

Linked Redeem Points

Action to redeem points from multiple linked members' purses in a single transaction. This action ensures atomic updates across all involved members and validates points availability before redemption.

Parameters

Parameter Type Format Description
Purse Name String Dropdown/Variable The purse policy to redeem points from. Select from dropdown or choose 'Variable' for dynamic purse names.
Points Array JSON Array of objects containing member IDs and point amounts to redeem. Format: [{memberId: string, points: number}]
Activity Object JSON Activity details to record with the redemption

JavaScript API

There is no JS API for this action.

Events Triggered

Generates the L2 RedeemPointsEvent for each member involved.

Possible Errors

Error Code Error Message Description
4002 A linked action %s was used with only one member, who is not the context member Invalid linked member context
2091 Linked member with id %s not found to add points Member specified in points array not found
4002 Please provide activity in options of LinkedAddPoints action Activity object missing
1200 Validation Error Activity validation failure
1726 Cannot unmerge with locked points Attempting to redeem locked points
2019 Failed to redeem %d points from purse %s because it has only %d points available Insufficient points
1823 Redemption in progress Concurrent redemption detected
1762 Transaction cannot update members Failed to update all members atomically

Additional Considerations

  • All member updates occur in a single transaction for consistency
  • Points validation happens before any redemptions start
  • Concurrent redemptions are detected and prevented
  • Activity records are created for each member involved
  • Points must be positive integers
  • All members must belong to the same program
Targeted Redeem Points

Targeted Redeem Points

This action redeems points from a specific activity's accruals.

Parameters

Parameter Type Format Description
Policy ID String Text ID of the purse policy
Purse Name String Text Optional. Name of purse if Policy ID is 'Variable'
Points Number Integer Number of points to redeem
Target Activity String Text ID of activity whose accruals to redeem from

JavaScript API

There is no JS API for this action.

Events Triggered

Generates L2 RedeemPointsEvent when points are redeemed.

Possible Errors

Error Code Error Message Description
1730 Invalid target activity The provided activity ID is invalid or not found
2040 Can not find purse in member with _id %s The specified purse wasn't found for the member
2019 Failed to redeem %d points from purse %s because it has only %d points available Insufficient points available in the purse
2091 Failed to redeem %d points from accruals of activity %s because it has only %d points available Insufficient points available in the target activity's accruals

Additional Considerations

  • Validates that the target activity ID is valid ObjectId
  • Validates that the purse exists and belongs to member
  • Checks the available points in the target activity's accruals
  • Cannot redeem more points than available in the target activity
  • Points can't be redeemed after the purse period close date
  • Generates events before the database updates
  • Updates both the purse balance and accrual records
Lock Points

Lock Points

This action locks points in a purse until a specified date.

Parameters

Parameter Type Format Description
Policy ID String Text ID of the purse policy
Points Number Text Number of points to lock
Locked Till Date Text Date until which the points is locked
Tag String Text Optional. Tag to identify the locked points

JavaScript API

UDF.lockPoints(policyId, points, lockedTill, tag, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
4011 Please provide valid locked till date The lockedTill date parameter is an invalid date or a date that's not in the future
2018 Can not find purse in member with _id %s Reported if provided purse is invalid
2080 The points to be locked from purse %s are invalid Reported if points value is invalid
2019 Failed to lock %d points from purse %s because it has only %d points available. Insufficient point balance for lock operation

Additional Considerations

  • Validates that the purse exists and belongs to the member
  • Points must be a positive number
  • Locked till date must be in the future
  • Points can't be locked after the purse period close date
  • Total locked points can't exceed purse balance
Unlock Points

Unlock Points

This action unlocks previously locked points in a purse.

Parameters

Parameter Type Format Description
Policy ID String Text ID of the purse policy
Lookup Field String Text Field to use for looking up the lock record
Lookup Value String Text Value to match in the lookup field

JavaScript API

UDF.unlockPoints(policyId, lookupField, lookupValue, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2081 Please provide required parameters in UnlockPoints action Required lookup parameters are missing
2018 Can not find purse in member with _id %s The specified purse wasn't found
2084 Points cannot be unlocked from member %s for purse %s after period close date %s Can't unlock points after purse period close date

Additional Considerations

  • Validates that the lookup field and value are provided
  • Validates that the purse exists and belongs to member
  • Can't unlock points after the purse period close date
  • Updates the locked points array in the purse
  • Returns the unlocked points records in the result
  • Supports multiple lock records matching the lookup criteria
  • Lookup field and value can be comma-separated for multiple matches
Expire Balance

Expire Balance

This action expires the balance in a purse.

Parameters

Parameter Type Format Description
Purse String Dropdown Select the purse policy to expire balance from
Purse Name String Text Optional. Name of the purse when using Variable purse policy

JavaScript API

UDF.expireBalance(purseId, purseName, callback)

Possible Errors

Error Code Error Message Description
2040 Can not find purse in member with _id %s Reported if provided purse is invalid
2070 Accrual expiry failed for purse: %s Reported if expiry operation fails

Additional Considerations

  • Validates purse exists before expiring balance
  • Purse Name parameter is only used when Purse is set to 'Variable'
  • Expires all eligible accruals in the purse
  • Updates purse balance after expiration
Expire Accruals

Expire Accruals

This action expires the balance associated with accruals that have reached their expiration date within a purse.

Parameters

Parameter Type Format Description
Purse String Dropdown Select the purse policy to expire balance from
Purse Name String Text Optional. Name of the purse when using Variable purse policy
MemberAvailable balance Number Integer Optional when Evaluate Expired Points is true. Snap of Member available balance to compare with current member state
Member lastActivityDate Date JS Date Optional when Evaluate Expired Points is true. Snap of Member lastActivityDate to compare with current member state
Points to Expire Number Integer Optional when Evaluate Expired Points is true. Expires the mentioned points if the provided the lastActivityDate and available matches with current member state
Evaluate Expired Points Boolean true/false If enabled, points are recalculated and expired at activity execution; otherwise, the provided available balance and last activity date are used to expire the specified points.

JavaScript API

UDF.expireAccruals(purseId, purseName, availableBalance, lastActivityDate, pointsToExpire,
        evaluateExpiredPoints, callback)

Possible Errors

Error Code Error Message Description
2040 Can not find purse in member with _id %s Reported if provided purse is invalid
2134 Activity failed in %s action due to data mismatch. Reported when current member state is different from provided last activity date and available balance.
2138 Invalid Points to Expire Reported if an invalid integer passed to expire points
2136 Activity failed in %s action due to pending redemption. Reported if any redemption is in progress
2137 Activity failed in %s action due to pending expiration. Reported if any expiration is in progress

Additional Considerations

  • Validates purse exists before expiring balance
  • Purse Name parameter is only used when Purse is set to 'Variable'
  • Expires all eligible accruals in the purse
  • Updates purse balance after expiration
Escrow Activity

Escrow Activity

This action escrows points from a previous activity.

Parameters

Parameter Type Format Description
External Txn Id String Text External transaction ID of the activity to escrow
Transaction Id String Text Transaction ID of the activity to escrow
Purse String Dropdown Select the purse policy to escrow points from
Purse Name String Text Optional. Name of the purse when using Variable purse policy
Value String Text Value to escrow. Examples: 10, *0.5, +12

JavaScript API

UDF.escrowActivity(externalTxnId, transactionId, purseId, purseName, value, callback)

Events Triggered

No events are generated by this action

Possible Errors

Error Code Error Message Description
2000 Can not find activity with given txnId/extTxnId %s in %s action Reported if no activity exists with the given ID
2018 Can not find purse in member with _id %s Reported if provided purse is invalid
1730 Invalid activity ID %s passed Reported if the transaction ID isn't a valid ObjectId
2084 Escrow activity failed for purse: %s, activity txnId/externalTxnId: %s Reported if escrow operation fails

Additional Considerations

  • At least one of External Txn Id or Transaction Id must be provided
  • Purse Name is only valid when Purse is set to 'Variable'
  • Original activity must exist and be in a valid state for escrow
Transfer In

Transfer In

This action transfers points from a transfer member to the context member.

Context Member

The context member refers to the member to whom the activity is being posted. This member receives the points transferred from another member.

Transfer Member

The transfer member is dynamically loaded based on the Lookup Field provided in the rule action. This member is the source of the points that are getting transferred.


Parameters

Parameter Type Format Description
Source Member _id or LoyaltyId String Text Enter the member identifier (member_id or loyaltyid) to fetch the transfer member.
Purse Name String Dropdown Select the purse to use. For variable purse names, choose "Variable" and specify the field.
Points Number Integer Number of points to transfer. Must be a positive, whole number.
Activity Payload Object JSON Overrides the activity payload sent by default through this action for the transfer member.
Accounting Type String Normal/Non-Revenue Categorizes the earn. Typically, non-revenue earn is given for non-purchase activities.
Expiration Date Date/Time JS Date Expiration date for points. Defaults to the Purse Policy setting.
Escrow Date Date/Time JS Date Escrow date for points. Defaults to the Purse Policy setting.

JavaScript API

There is no JS API for this action.


Execution Details

Context Member

The same activity is used to create the accrual using the points provided in the Points parameter.

Transfer Member Activity

The transfer member is fetched using the Lookup Field parameter. A new activity is created for the transfer member with the following payload:

{
  "type": "Transfer Out",
  "date": context.activity.utcDate || new Date(),
  "currencyCode": context.activity.currencyCode,
  "memberID": transferMember._id,
  "originalMemberID": transferMember._id,
  "srcChannelID": context.activity.srcChannelID,
  "srcChannelType": context.activity.srcChannelType,
  "value": context.activity.value,
  "status": "Processed",
  "result": {
    "data": {
      "purses": [
        {
          "name": "<Purse Name>",
          "prev": "<Balance before this action execution>",
          "prevAvail": "<Available Balance before this action execution>",
          "new": "<Balance after this action execution>",
          "newAvail": "<Available Balance after this action execution>"
        }
      ]
    }
  }
}

Error Handling

Member Not Found

  • If member_id is used and no matching member is found:

    Error Message: No member found with memberId "%s" in program "%s".

  • If loyaltyid is used and no matching member is found:

    Error Message: No member found with loyaltyID "%s" in program "%s".

Transfer Member is the Same as Context Member

  • If the transfer member is the same as the context member:

    Error Message: The target member must not be same as the source member.

Transfer Out

Transfer Out

This action transfers points from the context member to a transfer member.

Context Member

The context member refers to the member to whom the activity is being posted. This member gives the points to another member.

Transfer Member

The transfer member is dynamically loaded based on the Lookup Field provided in the rule action. This member is the recipient of the transferred points.


Parameters

Parameter Type Format Description
Target Member _id or LoyaltyId String Text Enter the member identifier (member_id or loyaltyid) to fetch the transfer member.
Purse Name String Dropdown Select the purse to use. For variable purse names, choose "Variable" and specify in the field.
Points Number Integer Number of points to transfer. Must be a positive, whole number.
Activity Payload Object JSON Overrides the activity payload sent by default through this action for the transfer member.
Accounting Type String Normal/Non-Revenue Categorizes the earn. Typically, non-revenue earn is given for non-purchase activities.
Expiration Date Date/Time JS Date Expiration date for points. Defaults to the Purse Policy setting.
Escrow Date Date/Time JS Date Escrow date for points. Defaults to the Purse Policy setting.

JavaScript API

There is no JS API for this action.


Execution Details

Context Member

The same activity is used to create the redemption using the points provided in the Points parameter.

Transfer Member Activity

The transfer member is fetched using the Lookup Field parameter. A new activity is created for the transfer member with the following payload:

{
  "type": "Transfer In",
  "date": context.activity.utcDate || new Date(),
  "currencyCode": context.activity.currencyCode,
  "memberID": transferMember._id,
  "originalMemberID": transferMember._id,
  "srcChannelID": context.activity.srcChannelID,
  "srcChannelType": context.activity.srcChannelType,
  "value": context.activity.value,
  "status": "Processed",
  "result": {
    "data": {
      "purses": [
        {
          "name": "<Purse Name>",
          "prev": "<Balance before this action execution>",
          "prevAvail": "<Available Balance before this action execution>",
          "new": "<Balance after this action execution>",
          "newAvail": "<Available Balance after this action execution>"
        }
      ]
    }
  }
}

Error Handling

Member Not Found

  • If member_id is used and no matching member is found:

    Error Message: No member found with memberId "%s" in program "%s".

  • If loyaltyid is used and no matching member is found:

    Error Message: No member found with loyaltyID "%s" in program "%s".

Transfer Member is the Same as Context Member

  • If the transfer member is the same as the context member:

    Error Message: The target member must not be same as the source member.

Transfer Accruals

Transfer Accruals

This action transfers usable accruals from the source member to a target member.


Parameters

Parameter Type Format Description
Purse Name String Dropdown Select the purse to use. For variable purse names, choose "Variable" and specify in the field.
Target Member _id or LoyaltyId String Text Enter the member identifier (member_id or loyaltyid) to fetch the target member.
Activity Payload Object JSON Overrides the activity payload sent by default through this action for the target member.

JavaScript API

There is no JS API for this action.


Execution Details

Source Member

  • Retrieve usable accruals of the source member(contex member).
  • Calculates the total available points from usable accruals to transfer.
  • Creates a single packaged redemption transaction with the total available points to mark exisiting accruals as used.

Target Member

  • Duplicates the source member accruals to the target member to ensure that the earn and expiration dates are accurately replicated.
  • Updates the target member’s purse by adding the transferred points.
  • Create a new activity on the target member, with type Transfer Accruals.
{
  "type": "Transfer Accruals",
  "date": context.activity.utcDate || new Date(),
  "currencyCode": context.activity.currencyCode,
  "memberID": targetMember._id,
  "originalMemberID": targetMember._id,
  "srcChannelID": context.activity.srcChannelID,
  "srcChannelType": context.activity.srcChannelType,
  "value": context.activity.value,
  "status": "Processed",
  "result": {
    "data": {}
  },
  "_internal": {
    "primaryActivityId": context.activity._id
  }
}

Possible Errors

Error Code Error Message Description
1847 %s member %s is being merged or unmerged. Please retry later Reported if any one of the members invloved in merge or unmerge porcess
1848 Purse name should not be empty. Reported if given purse name not found in either source or target
1849 Source member %s has no accruals to transfer. Reported if source member has no usable accruals
2145 The target member must not be same as the source member. Reported when the source and target have matching loyalty or member IDs.
4002 No member found with memberId "%s" in program "%s". or No member found with loyaltyID "%s" in program "%s". Reported when no matching member is found with provided loyaltyID or memberID.

Rewards

Give Reward

Give Reward

This action adds a reward to a member based on a reward policy. The reward can be configured with a custom code, usage limits, and expiration date. The reward's configuration is determined by the specified reward policy.

Parameters

Parameter Type Format Description
Reward String Dropdown Select the reward policy to use.
Reward Code String Text Optional. Custom code for the reward. If not provided, a UUID will be generated.
Reward Counter Number Integer Optional. Number of uses allowed. Defaults to policy's numUses value.
Check Limit Boolean Boolean Optional. Whether to enforce reward limits. Defaults to true.
Expiration Date Date/Time JS Date Optional. When the reward expires. If not provided, calculated from policy settings.

Outputs

Returns the created reward object.

JavaScript API

UDF.addReward(policyId, rewardCode, rewardCounter, checkLimit, expirationDate, cb)

Events Triggered

Possible Errors

Error Code Error Message Description
3001 Reward policy with "%s" "%s" not found while adding reward to member with unique id "%s" Reported if no matching reward policy found
1684 Reward does not belong to member program Reported if reward is not defined on the program to which the member belongs
1680 Reward cannot be added for member %s with status %s Reported if member status is not allowed for this reward
2023 Reward Policy has already expired on %s Reported if reward policy has expired
2014 Failed to use reward "%s". No more uses left Reported if reward policy doesn't allow issuing any more rewards

Additional Considerations

  • If checkLimit is false, reward limit validation errors are logged but not thrown
  • If no rewardCode is provided, a UUID is automatically generated
  • If no expirationDate is provided, it's calculated based on the policy's expirationHours and expirationSnapTo settings
  • If policy.availableRedemptions <= 0, throws an error
  • Reward's usesLeft defaults to policy.numUses if not specified
  • Reward's upc defaults to policy.upc if not specified
  • Validates the member status against policy.applicableMemberStatus if configured
  • Validates that the member program matches policy program
  • Validates the policy effectiveDate and expirationDate
  • Automatically sets the reward type to 'Reward'
  • Sets the reward name from the policy name
  • If the special flag 'allowFutureEffective' is enabled, the policy effective date validation is skipped
  • If the special flag 'ignoreDoubleApply' is enabled, uses left validation is skipped
  • If the special flag 'ignoreUsesLeft' is enabled, uses left validation is skipped
Give Specific Reward

Give Specific Reward

This action gives a specific reward to a member.

Parameters

Parameter Type Format Description
Reward Object Object Text Object containing reward details. See the Reward Structure for details on the object structure.
Check Limit Boolean Text Optional. Whether to check reward limits. Defaults to true
Reward Counter Number Text Optional. Counter for the reward

JavaScript API

UDF.addSpecificReward(rewardObj, checkLimit, rewardCounter, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
3001 Reward policy with "%s" "%s" not found while adding reward to member with unique id "%s" Reported if no matching reward policy was found
1684 Reward does not belong to member program Reported if reward isn't defined on the program to which the member belongs
1680 Reward cannot be added for member %s with status %s Reported if member status isn't allowed for this reward
2023 Reward Policy has already expired on %s Reported if the reward policy has expired
2014 Failed to use reward "%s". No more uses left Reported if the reward policy doesn't allow issuing any more rewards

Additional Considerations

  • If checkLimit is false, limit-related errors are ignored
  • Validates that the reward policy belongs to the member's program
  • Validates that the reward policy is within its effective period unless canPreview is true
  • Reward object must include the name and program fields
  • If reward code is provided and already exists, a new code will be generated
Give Reward by Name

Give Reward by Name

This action gives a reward to a member by name.

Parameters

Parameter Type Format Description
Reward Name String Text The name of the reward to give
Reward Code String Text Code for the reward
Reward Counter Number Text Number of times the reward can be used
Check Limit Boolean Text Optional. Whether to check reward limits. Defaults to true
Expiration Date Date Text Optional. Expiration date for the reward

JavaScript API

UDF.giveRewardByName(rewardName, rewardCode, rewardCounter, checkLimit, expirationDate, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
3001 Reward policy with "%s" "%s" not found while adding reward to member with unique id "%s" Reported if no matching reward policy found
1684 Reward does not belong to member program Reported if reward is not defined on the program to which the member belongs
1680 Reward cannot be added for member %s with status %s Reported if member status is not allowed for this reward
2023 Reward Policy has already expired on %s Reported if reward policy has expired
2014 Failed to use reward "%s". No more uses left Reported if reward policy doesn't allow issuing any more rewards

Additional Considerations

  • If checkLimit is false, limit-related errors are ignored
  • Validates that the reward belongs to the member's program
  • Validates that the reward is within its effective period unless canPreview is true
  • Expiration date must be after the effective date if provided
Give Reward by UPC

Give Reward by UPC

This action gives a reward to a member using UPC code.

Parameters

Parameter Type Format Description
Policy ID String Text ID of the reward policy
UPC String Text UPC code for the reward
Number of Uses Number Text Number of times the reward can be used
Reward Counter Number Text Counter for the reward
External Fields Object Text Optional. Additional fields to add to the reward
Expiration Date Date Text Optional. Expiration date for the reward

JavaScript API

There is no JS API for this action.

Events Triggered

Possible Errors

Error Code Error Message Description
3001 Reward policy with "%s" "%s" not found while adding reward to member with unique id "%s" Reported if no matching reward policy found
1684 Reward does not belong to member program Reported if reward is not defined on the program to which the member belongs
1680 Reward cannot be added for member %s with status %s Reported if member status is not allowed for this reward
2023 Reward Policy has already expired on %s Reported if reward policy has expired
2014 Failed to use reward "%s". No more uses left Reported if reward policy doesn't allow issuing any more rewards

Additional Considerations

  • If checkLimit is false, limit-related errors are ignored
  • Validates that the reward belongs to the member's program
  • Validates that the reward is within its effective period unless canPreview is true
  • Expiration date must be after the effective date if provided
  • External fields are merged into the reward object
Cancel Reward

Cancel Reward

This action cancels a reward by its code.

Parameters

Parameter Type Format Description
Reward Code String Text Code of the reward to cancel
Allow Expired Boolean Text Optional. Whether to allow canceling expired rewards
Allow Used Boolean Text Optional. Whether to allow canceling used rewards

JavaScript API

UDF.cancelReward(rewardCode, allowExpired, allowUsed, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2041 Reward with code "%s" not found Reported if the reward code is invalid or not found
2026 Reward with code "%s" expired Reported if the reward has expired and allowExpired is false
2027 Reward with code "%s" already used Reported if the reward has been used and allowUsed is false
2083 Cannot cancel locked reward Reported if attempting to cancel a locked reward

Additional Considerations

  • Validates that the reward exists before canceling
  • Checks the reward expiration status if allowExpired is false
  • Checks the reward usage status if allowUsed is false
  • Can't cancel rewards that are currently locked
Lock Reward

Lock Reward

This action locks a reward until a specified date, preventing it from being used until after that date.

Parameters

Parameter Type Format Description
Reward Code String Text Code of the reward to lock
Locked Till Date Text Date until which the reward is locked
Transaction ID String Text Optional. ID to track this lock operation

JavaScript API

UDF.lockReward(rewardCode, lockedTill, transactionId, callback)

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2074 Invalid locked till date The lockedTill date parameter is invalid or not in the future
2041 Can not find reward with code %s The specified reward code was not found
2071 Cannot use cancelled reward "%s" with code "%s" Can't lock a cancelled reward
2026 Failed to use reward "%s" with code "%s". It has already expired on %s Can't lock an expired reward
2025 Failed to use reward "%s" with code "%s". It will come into effective on %s Can't lock a reward that's not yet in effect
2119 Invalid lock transaction id The provided lock transaction ID is invalid

Additional Considerations

  • Validates that the reward exists and belongs to the member
  • Locked till date must be in the future
  • Can't lock cancelled rewards
  • Can't lock expired rewards
  • Can't lock rewards that aren't yet effective
  • Transaction ID must be valid if provided
Unlock Reward

Unlock Reward

This action unlocks a previously locked reward.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for looking up the reward
Lookup Value String Text Value to match in the lookup field
Lock Transaction ID String Text Transaction ID used when locking

JavaScript API

UDF.unlockReward(lookupField, lookupValue, lockTxnId, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2073 Please provide required parameters in Unlock Reward action Required parameters are missing
2074 Please provide valid locked till date The lockedTill date parameter is invalid
2076 No lockable matching reward found No matching reward found
2077 Locked till date cannot be updated since reward %s with code %s is cancelled Can't unlock a cancelled reward
2078 Locked till date cannot be updated since reward %s with code %s is already expired on %s Can't unlock an expired reward
2117 Locked till date cannot be updated since reward "%s" with code "%s" will come into effective on %s Cannot unlock a reward that's not yet in effect
2119 Invalid lock transaction id The provided lock transaction ID is invalid

Additional Considerations

  • Validates that the reward exists and belongs to member
  • Validates that the reward isn't cancelled, expired, or not yet in effect
  • Lock transaction ID must match the one used when locking
  • Updates the reward's locked till date to null
  • Returns silently if the reward is already unlocked
  • Can't unlock rewards that have been used
Lock Recent Reward by Type

Lock Recent Reward By Type

This action locks the most recently issued reward of a specific type until a specified date.

Parameters

Parameter Type Format Description
Reward Type String Text Type/Policy ID of the reward to lock
Locked Till Date Text Date until which the reward is locked
Options Object Text Optional. Additional options for locking

JavaScript API

UDF.lockRecentRewardByType(rewardType, lockedTill, options, callback)

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2073 Please provide required parameters in Lock Recent Reward By Type action Required parameters are missing
2074 Please provide valid locked till date The lockedTill date parameter is invalid or not in the future
2076 No lockable matching reward found No reward found matching the specified type
2071 Cannot use cancelled reward "%s" with code "%s" Can't lock a cancelled reward
2026 Failed to use reward "%s" with code "%s". It has already expired on %s Can't lock an expired reward
2025 Failed to use reward "%s" with code "%s". It will come into effective on %s Can't lock a reward that's not yet in effect

Additional Considerations

  • Validates that the reward type is provided
  • Locked till date must be in the future
  • Can't lock cancelled rewards
  • Can't lock expired rewards
  • Can't lock rewards that aren't yet effective
  • Finds and locks the most recently issued reward matching the type
Use Recent Reward by Type

Use Recent Reward By Type

Uses the most recently assigned reward of the specified type. This action is used to redeem the latest reward that matches the given type.

Parameters

Parameter Type Format Description
Type String Text The type of reward to use. Must match an existing reward type.

JavaScript API

UDF.useRecentRewardByType(type)

Events Triggered

Generates the L2 UseRecentRewardByTypeEvent.

Possible Errors

Error Code Error Message Description
2044 Usable rewards with types "%s" were not found. No reward was found matching the specified type
2024 Reward policy not found with id %s The reward wasn't found
2025 Failed to use reward "%s". It will come into effective on %s The reward isn't currently effective
2026 Failed to use reward "%s". It has alreay expired on %s The reward has expired
2027 Failed to use reward "%s". No more uses left. The reward has reached its maximum number of uses
2071 Cannot use cancelled reward "%s" with code "%s". The reward has been cancelled
1200 Validation Error Invalid parameters provided
9999 Unable to process: Type is required The type parameter wasn't provided

Additional Considerations

  • The reward must be assigned to the member before it can be used
  • The reward must be within its effective dates
  • The reward must not have exceeded its maximum uses
  • The reward must not be cancelled
  • Only the most recently assigned reward of the specified type is used
  • The reward type is case sensitive
  • If multiple rewards of the same type exist, the most recently assigned one is used
Use Reward by Code

Use Reward By Code

Uses a reward by its code. This action redeems a reward that was assigned to a member using a code.

Parameters

Parameter Type Format Description
Code String Text The code to use. The code must be assigned to the member and be valid.

JavaScript API

UDF.useRewardByCode(code)

Events Triggered

Generates the L2 UseRewardByCodeEvent.

Possible Errors

Error Code Error Message Description
2044 Reward with code "%s" not found. The reward code wasn't found
2024 Reward policy not found with id %s The reward policy wasn't found
2025 Failed to use reward "%s". It will come into effective on %s The reward isn't currently in effect
2026 Failed to use reward "%s". It has alreay expired on %s The reward has expired
2027 Failed to use reward "%s". No more uses left. The reward has reached its maximum number of uses
2071 Cannot use cancelled reward "%s" with code "%s". The reward has been cancelled
1200 Validation Error Invalid parameters provided
9999 Unable to process: Code is required The code parameter wasn't provided

Additional Considerations

  • The reward must be assigned to the member before it can be used
  • The reward must be within its effective dates
  • The reward must not have exceeded its maximum uses
  • The reward must not be cancelled

Offers

Give Offer by Lookup

Give Offer by Lookup Field

This action gives an offer to a member using lookup field.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for looking up the offer
Lookup Value String Text Value to match in the lookup field
Offer Counter Number Text Number of times the offer can be used
Check Limit Boolean Text Optional. Whether to check offer limits. Defaults to true
Expiration Date Date Text Optional. Expiration date for the offer
Future Effective Boolean Text Optional. Whether the offer can be in effect in the future

JavaScript API

UDF.giveOfferByLookup(lookupField, lookupValue, offerCode, offerCounter, checkLimit, expirationDate, futureEffective, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
3001 Reward policy with %s %s not found while adding offer to member with unique id %s. Reported if no matching reward policy found
1684 Offer does not belong to member program. Reported if offer is not defined on the program to which the member belongs
1680 Offer cannot be added for member %s with status %s.' Offer can not added due to invalid member status. Please check the Reward Policy allowed member satuses
2023 Reward Policy has already expired on %s. Reward policy has expired.
2014 Failed to use offer "%s". No more uses left. The offer reward policy doesn't allow issuing any more offers.

Additional Considerations

  • If checkLimit is false, limit-related errors are ignored
  • Validates offer belongs to member's program
  • Validates offer is within its effective period unless canPreview is true or special flag of futureEffective is true
  • Expiration date must be after the effective date if provided
Give Offer by Lookup with Params

Give Offer by Lookup Field With Params

This action gives an offer to a member using lookup field and additional parameters.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for looking up the offer
Lookup Value String Text Value to match in the lookup field
Params Object Text Additional parameters for the offer
Offer Counter Number Text Number of times the offer can be used
Check Limit Boolean Text Optional. Whether to check offer limits. Defaults to true

JavaScript API

UDF.giveOfferByLookupWithParams(lookupField, lookupValue, params, offerCounter, checkLimit, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2015 No offer Reported if lookup field or value is missing
3001 Reward policy with %s %s not found while adding offer to member with unique id %s. Reported if no matching reward policy found
1684 Offer does not belong to member program. Reported if offer is not defined on the program to which the member belongs
1680 Offer cannot be added for member %s with status %s.' Offer can not added due to invalid member status. Please check the Reward Policy allowed member satuses
2023 Reward Policy has already expired on %s. Reward policy has expired.
2014 Failed to use offer "%s". No more uses left. The offer reward policy doesn't allow issuing any more offers.

Additional Considerations

  • If checkLimit is false, limit-related errors are ignored
  • Params object can include custom fields that will be added to the offer
  • Validates that the offer belongs to the member's program
  • Validates that the offer is within its effective period unless canPreview is true
Lock Offer

Lock Offer

This action locks an offer until a specified date.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for looking up the offer
Lookup Value String Text Value to match in the lookup field
Locked Till Date Text Date until which the offer is locked
Locked Transaction ID String Text Transaction ID for the lock operation

JavaScript API

UDF.lockOffer(lookupField, lookupValue, lockedTill, lockTxnId, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2108 Please provide lookup field and/or lookup value Reported if required parameters are missing
2109 Please provide valid locked till date Reported if locked till date is invalid
2111 Locked till date cannot be updated since offer with field %s and value %s does not exist for the member Reported if no matching offer found
2110 Locked till date cannot be updated since offer %s with code %s is already used Reported if offer is already used
2112 Locked till date cannot be updated since offer %s with code %s is cancelled Reported if offer is cancelled
2113 Locked till date cannot be updated since offer %s with code %s is already expired Reported if offer has expired
2114 Global offer "%s" is not lockable/unlockable Reported if trying to lock a global offer
2115 Please provide lock transaction id Reported if lock transaction ID is missing
2116 Please provide a valid lock transaction id Reported if lock transaction ID is invalid
2118 Locked till date cannot be updated since offer "%s" with code "%s" will come into effective on %s Reported if offer isn't yet in effect
2120 Multi use offer "%s" is not lockable/unlockable Reported if trying to lock a multi-use offer

Additional Considerations

  • Validates that the offer exists and belongs to the member
  • Validates that the offer isn't already used, cancelled, or expired
  • Can't lock global offers or multi-use offers
  • Lock transaction ID is required and must be valid
  • Locked till date must be valid and in the future
Unlock Offer

Unlock Offer

This action unlocks a previously locked offer.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for looking up the offer
Lookup Value String Text Value to match in the lookup field
Lock Transaction ID String Text Transaction ID used when locking

JavaScript API

UDF.unlockOffer(lookupField, lookupValue, lockTxnId, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2108 Please provide lookup field and/or lookup value Required parameters are missing
2111 Locked till date cannot be updated since offer with field %s and value %s does not exist for the member No matching offer found
2112 Locked till date cannot be updated since offer %s with code %s is cancelled Cannot unlock a cancelled offer
2113 Locked till date cannot be updated since offer %s with code %s is already expired Cannot unlock an expired offer
2114 Global offer "%s" is not lockable/unlockable Cannot unlock a global offer
2115 Please provide lock transaction id Lock transaction ID is missing
2116 Please provide a valid lock transaction id Lock transaction ID is invalid
2118 Locked till date cannot be updated since offer "%s" with code "%s" will come into effective on %s Cannot unlock an offer that's not yet in effect
2120 Multi use offer "%s" is not lockable/unlockable Cannot unlock a multi-use offer

Additional Considerations

  • Validates that the offer exists and belongs to member
  • Validates that the offer isn't cancelled, expired, or not yet in effect
  • Can't unlock global offers or multi-use offers
  • Lock transaction ID is required and must be valid
  • Must match the transaction ID used when locking
  • Updates offer's locked till date to null
Use Offer by Code

Use Offer By Code

Uses an offer by its code. This action redeems an offer that was assigned to a member using a code.

Parameters

Parameter Type Format Description
Code String Text The code to use. The code must be assigned to the member and be valid.

Outputs

None

JavaScript API

UDF.useOfferByCode(code)

Events Triggered

Generates the L2 UseOfferEvent.

Possible Errors

Code Message Description
2011 Can not find offer with _id %s The offer associated with the code wasn't found
2012 Offer with _id %s is not effective The offer isn't currently in effect (outside start/end dates)
2013 Offer with _id %s has expired The offer has expired
2014 No more uses available for offer with _id %s The offer has reached its maximum number of uses
2072 Offer with _id %s is cancelled The offer has been cancelled
1200 Validation Error Invalid parameters were provided
9999 Unable to process: Code is required The code parameter wasn't provided

Additional Considerations

  • The offer must be assigned to the member before it can be used
  • The offer must be within its effective dates
  • The offer must not have exceeded its maximum uses
  • The offer must not be cancelled
Apply Offers

Apply Offers

This action applies the best offers to the current activity based on the activity's best offers list.

Parameters

Parameter Type Format Description
Ignore Missing Object JSON Configuration for whether to raise errors for missing offers/rewards. Defaults to: { ignoreGlobalOffer: false, ignoreOffer: false, ignoreReward: false }

JavaScript API

UDF.applyOffers(ignoreMissing, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2011 Offer not found Reported if an offer cannot be found
2012 Offer not effective Reported if an offer's effective date is in the future
2013 Offer expired Reported if an offer has expired
2014 No more uses left Reported if an offer has no remaining uses
2015 No offer Reported if no offers are available to apply

Additional Considerations

  • Uses the activity's bestOffers list to determine which offers to apply
  • If ignoreGlobalOffer is false, throws an error when global offer policies aren't found
  • If ignoreOffer is false, throws an error when an offer isn't found for the member
  • If ignoreReward is false, throws an error when a reward isn't found for the member
  • Validates offer effective dates and expiration dates before applying
Check Offer Limits

Check Offer Limits

This action checks if a member has exceeded offer or reward limits based on configured thresholds.

Parameters

Parameter Type Format Description
Entity String Dropdown Type of entity to check limits for. Select from LimitPolicyType enum
Policy Filter Object JSON Optional. Filter to select specific policies. Defaults to {}
Limits Object JSON Optional. Limit thresholds to check. Example: {perOffer: 10, perMonth: 5, perWeek: 2, perDay: 1}
Calendar Boolean Boolean Whether to use calendar months/weeks vs rolling periods

Outputs

Sets Context.limitExceeded to true if any limit is exceeded, false otherwise.

JavaScript API

UDF.checkOfferLimits(entityType, policyFilter, limits, isCalendar, callback)

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
1732 Limit already exists Reported if attempting to check a duplicate limit
1738 Invalid limit value Reported if a limit value is invalid
1759 Type mismatch Reported if entity type doesn't match policy type

Additional Considerations

  • Supports daily, weekly, and monthly limits
  • Week boundaries determined by program's weekStartDay setting
  • Calendar mode uses fixed month/week boundaries
  • Non-calendar mode uses rolling periods
  • Checks both transient and stored records
Update Member Offer With Params

Update Member Offer With Params

This action applies the provided lookups and offer filter to identify relevant member offers and updates their attributes.

Parameters

Parameter Type Format Description
Lookup Field String Text Optional. The field to query on member offers
Lookup Value String Text Optional. Values to be used for lookup
Offer Filter Object JSON Optional. Additional filters to apply to the query
Offer Object Object JSON A JSON string containing the attributes to be updated

Outputs

The updates are applied to each member offer record filtered using the provided lookup fields and values. If an offer filter is provided and its key matches a lookup field, the filter conditions are combined with the existing lookups; otherwise, the filter is applied alongside the existing criteria.

JavaScript API

UDF.updateMemberOfferWithParams(lookupField, lookupValue, offerFilter, offerObj, callback)

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2108 Please provide either a valid lookup field with its corresponding lookup value or a non-empty, valid offer filter Required parameters are missing
2108 Lookup values are missing for the provided lookup fields Reported when a lookup value is missing for a specified lookup field
2126 The number of lookup fields must match the number of lookup values Reported when the count of lookup fields and lookup values do not align
2127 Invalid format for lookupValues. Please ensure it follows a proper JSON-like structure Reported when the lookupValues are provided in an invalid JSON format
4011 The date provided %s for %s field is not in a valid format Reported when the date format is invalid
2128 The effectiveDate for offer %s cannot be updated because it falls after the offer's expirationDate %s Reported when setting an offer's effectiveDate later than its expirationDate
2129 The expiresOn for offer %s cannot be updated because it occurs before the offer's effectiveDate %s Reported when setting an offer's expiration date earlier than its effectiveDate
4034 Please provide a valid "Offer update object" Reported when the provided offer update object isn't valid

Additional Considerations

  • The offer must be assigned to the member before its attributes can be updated
  • Returns silently if the offer matching the filters isn't found
  • Sets the updatedAt and updatedBy fields automatically
  • Updates the attributes of the member's offer based on the applied filters

Promo Codes

Assign Promo Code

Assign Promo Code

This action assigns a promo code from a campaign to a member.

Parameters

Parameter Type Format Description
Campaign Code String Text The campaign code to assign a promo code from

JavaScript API

UDF.assignPromoCode(campaignCode, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2087 Promo campaign with code %s not found Reported if the promo campaign code isn't found
2088 Promo campaign with code %s expired Reported if the promo campaign has expired
2090 Promo campaign with code %s not started Reported if the promo campaign's start date is in the future

Additional Considerations

  • Validates that the campaign exists and is within its effective period
  • Updates the promo code status from 'New' to 'Assigned'
  • Sets the assignment date to the current time
  • Validates that the campaign belongs to the member's program
Redeem Promo Code

Redeem Promo Code

This action redeems a promo code that has been assigned to the member.

Parameters

Parameter Type Format Description
Promo Code String Text Code to redeem

JavaScript API

UDF.redeemPromoCode(promoCode, callback)

Outputs

Populates Context.result.data.promoCodes with array containing the redeemed promo code object.

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2089 Promo code %s to be redeemed not found The specified promo code was not found or isn't assigned to the member
2088 Promo campaign with code %s expired The promo campaign has expired
2090 Promo campaign with code %s not started The promo campaign hasn't started yet

Additional Considerations

  • Validates that the promo code exists and is assigned to member
  • Checks the campaign start and end dates
  • Updates the promo code status to 'Redeemed'
  • Sets the redemption date to the current activity date
  • Updates the context with the redeemed code details
  • Combines with any existing promo codes in context
Assign and Redeem Promo Code

Assign And Redeem Promo Code

This action assigns and immediately redeems a promo code in a single operation.

Parameters

Parameter Type Format Description
Promo Code String Text The promo code to assign and redeem

JavaScript API

UDF.assignAndRedeemPromoCode(promoCode, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2089 Promo code %s to be redeemed not found Reported if the promo code doesn't exist or isn't available
2088 Promo campaign with code %s expired Reported if the promo campaign has expired
2090 Promo campaign with code %s not started Reported if the promo campaign's start date is in the future

Additional Considerations

  • Validates that the promo code exists and is in 'New' status
  • Updates the promo code status directly from 'New' to 'Redeemed'
  • Sets both assignment and redemption dates to the current time
  • Validates that the campaign belongs to the member's program

Activities & Events

Lookup Activities

Lookup Activities

This action looks up and populates activities for the current member within a specified date range.

Parameters

Parameter Type Format Description
From Date Date Text Optional. Start date for activity lookup. Defaults to start of current day
Limit Number Integer Optional. Maximum number of activities to return
Status String Text Optional. Filter by activity status(es). Comma-separated list
Type String Text Optional. Filter by activity type

JavaScript API

UDF.populateActivities(fromDate, limit, status, type, callback)

Outputs

Populates Context.member.activities with an array of activity objects.

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
4011 The From Date is not in a valid format Invalid date format
4037 The From date is not within the allowed range of 1900 to 3999 Invalid date range

Additional Considerations

  • If fromDate isn't provided, it defaults to the start of the current day
  • Activities are filtered by member ID and original member ID (unless disOriginalMemIdHisLookup is enabled)
  • Activities are filtered to be between fromDate and the current activity date
  • Respects program setting disOriginalMemIdHisLookup to control whether to lookup by original member ID
  • Status parameter can be a comma-separated list of statuses to filter by
Lookup Activity by ID

Lookup Activity By ID

This action looks up and populates a specific activity by its ID.

Parameters

Parameter Type Format Description
Activity ID String Text ID of the activity to lookup

JavaScript API

UDF.populateActivityById(activityId, callback)

Outputs

Populates Context.member.activities array with the found activity object.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Returns immediately if activity ID is invalid or not provided
  • Returns silently if the activity isn't found
Lookup Activity by Params

Lookup Activity By Params

This action looks up and populates activities matching specified parameters.

Parameters

Parameter Type Format Description
Lookup Field String Text Comma-separated list of fields to match on
Lookup Value String Text Comma-separated list of values corresponding to lookup fields

JavaScript API

UDF.populateActivityByParams(lookupField, lookupValue, callback)

Outputs

Populates Context.member.activities with matching activity objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Returns immediately if lookup field or value isn't provided
  • Returns silently if no matching activities are found
  • Supports multiple lookup fields and values as comma-separated lists
  • Values must match in order with their corresponding lookup fields
Cancel Transaction

Cancel Transaction

This action cancels a previous transaction by either its activity ID or external transaction ID.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for finding the transaction. Either '_id' or 'externalTxnId'. Defaults to 'externalTxnId'
Value String Text Value of the lookup field to identify the transaction to cancel

JavaScript API

UDF.cancelTransaction(lookupField, value, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
2033 Activity with external transaction ID not found Reported if the transaction can't be found by external ID
1730 Invalid activity ID Reported if the provided activity ID is invalid
1731 Invalid lookup field Reported if lookup field isn't '_id' or 'externalTxnId'

Additional Considerations

  • Reverses all point transactions from the original activity
  • Cancels any rewards or offers that were issued
  • Updates the original activity status to indicate cancellation
  • Maintains an audit trail of the cancellation
Create Metric Event

Create Metric Event

This action creates a metric event for aggregating member data.

Parameters

Parameter Type Format Description
Event Payload Object JSON Configuration for the metric event. See structure below.

The Event Payload object must contain:

{
  name: string,         // The name of the metric being populated
  aggregates: string,   // Comma separated list of aggregates to populate (daily, weekly, monthly, quarterly, halfyearly, yearly, lifetime)
  value: number,        // Value to be recorded for the metric
  date: Date,          // Optional. The date for recording the metric. Defaults to activity date
  expirationDate: Date // Optional. When the metric expires
}

JavaScript API

There is no JS API for this action.

Events Triggered

Possible Errors

Error Code Error Message Description
9999 The metric event payload is missing Reported if no payload is provided
9999 The metric event name is missing Reported if name is missing or equals ''
9999 The metric aggregate types missing Reported if aggregates is missing or equals ''
9999 The metric aggregate value is missing Reported if value is missing or equals ''
9999 Invalid Aggregate type/types Reported if any aggregate type isn't one of the allowed values

Additional Considerations

  • Supports daily, weekly, monthly, quarterly, halfyearly, yearly, and lifetime aggregates
  • Multiple aggregate types can be specified in a comma-separated list
  • Date values are validated before processing
  • Value is rounded to 0 if not provided or invalid
Generate Custom Event

Generate Custom Event

This action generates a custom event with the provided data.

Parameters

Parameter Type Format Description
Data Object Text The data to include in the custom event payload

JavaScript API

UDF.generateCustomEvent(data, callback)

Events Triggered

Possible Errors

This action doesn't throw any errors.

Additional Considerations

  • Only generates an event if data is provided and not empty
  • Event includes the user ID and member ID in the header
  • Creates member.events array if it doesn't exist

Lookups

Lookup Activity Offers

Lookup Activity Offers

This action looks up and populates offer coupons associated with the current activity.

Parameters

None. Uses the current activity context.

JavaScript API

UDF.populateActivityCouponOffers(callback)

Outputs

Populates the current activity with:

  • activity.coupon: The main activity coupon if activity.couponCode exists
  • activity.lineItems[].coupon: Individual line item coupons if lineItems[].couponCode exists

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Looks up coupons by code from the Offer collection
  • Only returns coupons with usesLeft > 0
  • Sorts by the expiration date when multiple matches exist
  • Attaches coupons to both the activity level and the line item level
  • Returns silently if no matching coupons are found
Lookup Activity Rewards

Lookup Activity Rewards

This action looks up and populates reward coupons associated with the current activity.

Parameters

None. Uses the current activity context.

JavaScript API

UDF.populateActivityCouponRewards(callback)

Outputs

Populates the current activity with:

  • activity.coupon: The main activity coupon if activity.couponCode exists and mathes the Reward code
  • activity.lineItems[].coupon: Individual line item coupons if lineItems[].couponCode exists and matches the Reward code

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Looks up coupons by code from the Reward collection
  • Only returns coupons with usesLeft > 0
  • Sorts by the expiration date when multiple matches exist
  • Attaches coupons to both the activity level and the line item level
  • Returns silently if no matching coupons are found
Lookup Applicable Offers

Lookup Applicable Offers

This action finds all applicable offers for the current activity and member.

Parameters

Parameter Type Format Description
Best Offers Filter Object JSON Optional. Filter criteria for offers
Policy Filter Object JSON Optional. Additional filters to apply to the policies.
Line Item Exclusion Filter Object JSON Optional. Filter criteria for line items
Options Object JSON Optional. Additional options like lockTxnId
Populate Fields Object JSON Optional. Fields to populate from policies

JavaScript API

UDF.populateApplicableOffers(filterOfferTypes, policyFilter, lineItemFilter, options, populateFields, callback)

Populates Context.result.data.applicableOffers with array of applicable offers/rewards.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Validates all offers/rewards exist and are usable
  • Checks the offers/rewards cancellation status
  • Verifies the offers/rewards effective dates
  • Validates the remaining offers/rewards uses
  • Handles both global and member-specific offers (wallet offers/rewards)
  • Supports offer budget constraints
  • Applies location overrides if configured
  • Serializes line items if SPECIAL_FLAGS includes 'serializeLineItems'
Lookup Best Offers

Lookup Best Offers

This action finds the best applicable offers for the current activity and member.

Parameters

Parameter Type Format Description
Populate Fields Object JSON Optional. Fields to populate from policies
Offer Filter Object JSON Optional. Filter criteria for offers
Line Item Filter Object JSON Optional. Filter criteria for line items
Options Object JSON Optional. Additional options like lockTxnId
Include Applicable Offers Boolean Text Optional. Whether to load all the applicable offers to given lineitems and puts that on UDF.select('$.Context.result.data.applicableOffers).
Policy Filter Object JSON Optional. Additional filters to apply to the policies.

JavaScript API

UDF.populateBestOffers(populateFields, offerFilter, lineItemFilter, options, callback)

Outputs

Populates Context.result.data with: - bestOffers: Array of best applicable offers - repricedTicket: Activity with applied discounts - applicableOffers: Array of all applicable offers

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Validates that all offers exist and are usable
  • Checks the offer cancellation status
  • Verifies the offer effective dates
  • Validates the remaining offer uses
  • Handles both global and member-specific offers (wallet offers)
  • Supports offer budget constraints
  • Applies location overrides if configured
  • Optimizes offer combinations for maximum discount
  • Serializes line items if SPECIAL_FLAGS includes 'serializeLineItems'
Lookup Best Offer Policies

Lookup Best Offer Policies

This action looks up and populates offer policies corresponding to best offers.

Parameters

Parameter Type Format Description
Lookup Field String Text Field to use for looking up policies
Ignore Missing Boolean Text Optional. Whether to ignore missing policies

JavaScript API

There is no JS API for this action.

Outputs

Updates best offers in Context.activity.bestOffers with resolved policy IDs.

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2108 Please provide required parameters in Best Offer Policies action Lookup field parameter is missing
2011 The offer policies corresponding to best offers do not exist with query %s No matching policies found
2012 The offer policies corresponding to best offers lookup values %s do not exist Some lookup values didn't match any policies

Additional Considerations

  • Validates lookup field is provided
  • Looks up policies by the specified field
  • Updates originalPolicyId and policyId in best offers
  • Logs missing policies if ignoreMissing is true
  • Only processes global offers that don't already have originalPolicyId
Lookup Contextual Reward Policies

Lookup Contextual Reward Policies

This action finds applicable reward policies based on the current activity context, optionally filtered by type and balance requirements.

Parameters

Parameter Type Format Description
Lookup Field String Text Optional. Field to filter policies by
Lookup Value String Text Optional. Value to match against lookup field
Policy Filter Object JSON Optional. Additional filter criteria for policies
Line Item Exclusion Filter Object JSON Optional. Filter to exclude certain line items
Balance Number Text Optional. Points balance to check against policy costs
Max Policies Number Integer Optional. Maximum number of policies to return

JavaScript API

UDF.promptApplicablePolicies(lookupField, lookupValue, policyFilter, lineItemExclusionFilter, balance, maxPolicies, callback)

Outputs

Populates Context.result.data.applicablePolicies with array of:

  • policy: The reward policy object
  • discountAmount: Maximum possible discount for this policy

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
1807 Balance should be a number in Lookup Contextual Reward Policies action Balance parameter must be numeric
1807 MaxPolicies should be a number in Lookup Contextual Reward Policies action MaxPolicies parameter must be numeric

Additional Considerations

  • Validates numeric parameters (balance, maxPolicies)
  • Filters policies by:
    • Available redemptions > 0
    • Expiration date >= activity date
    • Budget > 0 for offers
    • Cost <= balance (if balance provided)
  • Applies location overrides if configured
  • Calculates maximum possible discount for each policy
  • Sorts results by discount amount (descending)
  • Returns top N results if maxPolicies is specified
  • Handles both rewards and offers with budget constraints
Lookup Eligible Offers

Lookup Eligible Offers

This action finds all eligible offers for the current activity and member based on policy and line item filters.

Parameters

Parameter Type Format Description
Policy Filter Object JSON Optional. Filter criteria for reward policies
Offer Filter Object JSON Optional. Filter criteria for offers (filterOffer, filterReward, filterGlobalOffer)
Line Item Filter Object JSON Optional. Filter to exclude certain line items

JavaScript API

UDF.getEligibleOffers(policyFilter, offerFilter, lineItemFilter, callback)

Outputs

Populates Context with:

  • eligibleOffers: Array of eligible offers
  • eligibleRewardPolicies: Array of eligible reward policies with applicable product lines

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Filters offers based on:
    • Member's program
    • Location overrides if configured
    • Policy criteria if provided
    • Line item criteria if provided
  • Calculates applicable product lines for each reward policy
  • Handles different discount types:
    • Ticket
    • Mix and Match
    • Combo
    • ComboList
  • Supports filtering by:
    • Regular offers
    • Reward offers
    • Global offers
  • Logs debug information about policy filtering and location overrides
Lookup Enums

Lookup Enums

This action looks up and populates enums of specified types.

Parameters

Parameter Type Format Description
Enum Types String Text Optional. Comma-separated list of enum types to lookup

JavaScript API

UDF.populateEnums(enumTypes, callback)

Outputs

Populates Context.activityEnums with array of matching enum objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • If no enum types are provided, logs a debug message and returns
  • Filters enums by language 'en'
  • Combines with any existing enums in Context.activityEnums
  • Uses cached enum data when available
  • Returns all enums if no types are specified
  • Deduplicates enum values using Set
Lookup Linked Member Offers

Lookup Linked Member Offers

This action looks up and populates offers for all members linked to the current member's account.

Parameters

Parameter Type Format Description
From Date Date Text Optional. Start date for offer lookup
Usable Boolean/Object Text Optional. Filter for usable offers or custom filter criteria

JavaScript API

UDF.populateLinkedMemberOffers(fromDate, usable, callback)

Outputs

Populates each linked member in Context.linkedAccount.members with:

  • offers: Array of offer objects

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
4011 The From Date is not in a valid format Invalid date format
4037 The From date is not within the allowed range of 1900 to 3999 Invalid date range

Additional Considerations

  • Filters offers by:
    • Member ID from linked members array
    • From date if provided
    • Usable status (not cancelled, has uses left, not expired) if usable=true
    • Custom filter criteria if usable is an object
  • Marks all loaded offers as transitive
  • Combines offers from both database and member's transient data
  • Skips loading if linked members aren't populated
Lookup Linked Member Rewards

Lookup Linked Member Rewards

This action looks up and populates rewards for all members linked to the current member's account.

Parameters

Parameter Type Format Description
From Date Date Text Optional. Start date for reward lookup
Usable Boolean/Object Text Optional. Filter for usable rewards or custom filter criteria

JavaScript API

UDF.populateLinkedMemberRewards(fromDate, usable, callback)

Outputs

Populates each linked member in Context.linkedAccount.members with:

  • rewards: Array of reward objects

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
4011 The From Date is not in a valid format Invalid date format
4037 The From date is not within the allowed range of 1900 to 3999 Invalid date range

Additional Considerations

  • Filters rewards by:
    • Member ID from linked members array
    • From date if provided
    • Usable status (not cancelled, has uses left, not expired) if usable=true
    • Custom filter criteria if usable is an object
  • Marks all loaded rewards as transitive
  • Combines rewards from both database and member's transient data
  • Skips loading if linked members aren't populated
Lookup Location

Lookup Location

This action looks up and populates location information for the current activity.

Parameters

Parameter Type Format Description
Lookup Fields String Text Optional. Comma-separated list of fields to match on. If not provided, matches on srcChannelID

JavaScript API

UDF.populateLocation(lookupFields, callback)

Outputs

Populates Context.activity with:

  • location: The matched location object
  • utcOffset: Timezone offset from location or program default
  • utcDate: Activity date adjusted for timezone

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • If no lookup fields are provided, matches on activity.srcChannelID
  • Uses location timezone if available, otherwise uses the program's default UTC offset
  • Sets activity.utcDate based on the timezone offset
  • Handles location overrides for rules if configured
  • Returns silently if no matching location is found
Lookup Member Offers

Lookup Member Offers

This action looks up and populates offers associated with the current member.

Parameters

Parameter Type Format Description
From Date Date Text Optional. Start date for offer lookup
Usable Boolean/Object Text Optional. Filter for usable offers or custom filter criteria

JavaScript API

UDF.populateMemberOffers(fromDate, usable, callback)

Outputs

Populates Context.member.offers with array of offer objects.

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
4011 The From Date is not in a valid format Invalid date format
4037 The From date is not within the allowed range of 1900 to 3999 Invalid date range

Additional Considerations

  • Filters offers by:
    • Member ID
    • From date if provided
    • Usable status (not cancelled, has uses left, not expired) if usable=true
    • Custom filter criteria if usable is an object
  • Marks all loaded offers as transitive
  • Returns an empty array if no offers are found
Lookup Member Preferences

Lookup Member Preferences

This action looks up and populates preferences for the current member.

Parameters

Parameter Type Format Description
Name String Text Optional. Name of preference to lookup. If not provided, returns all preferences

JavaScript API

UDF.populateMemberPreferences(name, callback)

Outputs

Populates Context.member.preferences with array of preference objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Returns early if preference already exists in member.preferences
  • Filters preferences by:
    • Member ID
    • Expiration date > current date
    • Preference name if provided
  • Handles cancelled preferences by removing them from results
  • Returns an empty array if no preferences are found
Lookup Member Rewards

Lookup Member Rewards

This action looks up and populates rewards associated with the current member.

Parameters

Parameter Type Format Description
From Date Date Text Optional. Start date for reward lookup
Usable Boolean/Object Text Optional. Filter for usable rewards or custom filter criteria

JavaScript API

UDF.populateMemberRewards(fromDate, usable, callback)

Outputs

Populates Context.member.rewards with array of reward objects.

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
4011 The From Date is not in a valid format Invalid date format
4037 The From date is not within the allowed range of 1900 to 3999 Invalid date range

Additional Considerations

  • Filters rewards by:
    • Member ID
    • From date if provided
    • Usable status (not cancelled, has uses left, not expired) if usable=true
    • Custom filter criteria if usable is an object
  • Marks all loaded rewards as transitive
  • Returns an empty array if no rewards are found
Lookup Partner

Lookup Partner

This action looks up and populates partner information for the current activity.

Parameters

Parameter Type Format Description
Partner Code String Text Optional. Code of partner to lookup. If not provided, uses activity.partnerCode

JavaScript API

UDF.populatePartner(partnerCode, callback)

Outputs

Populates Context.activity.partner with the partner object

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
1669 Rule partners not found The specified partner code wasn't found

Additional Considerations

  • If no partner code is provided, uses activity.partnerCode
  • Returns early if a partner code isn't provided
  • Returns silently if the partner isn't found
  • Excludes internal fields from the returned partner object
  • Supports passing partner object directly instead of code
Lookup Products

Lookup Products

This action looks up and populates product information for activity line items.

Parameters

Parameter Type Format Description
Apply To String Text Optional. Where to apply products ('Activity' or 'Repriced Ticket'). Defaults to 'Activity'
Lookup Fields String Text Optional. Field to use for product lookup (such as 'name:type'). Defaults to 'sku:itemSKU'

JavaScript API

UDF.populateProducts(applyTo, lookupFields, callback)

Outputs

Populates Context with:

  • activityProducts: Array of products with line numbers and quantities
  • Updates line items in activity or repricedTicket with product information

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2017 Products with were not found. The specified products weren't found and no 'Missing Product' was defined in the Products of RCX
2058 Multiple products found with overlapping effective dates Found products with overlapping effective dates

Additional Considerations

  • If no lookup fields are provided, uses 'sku:itemSKU' as default
  • Supports productId lookup if line items have the productId field
  • Validates product effective dates against the activity date
  • Handles missing products by using 'Missing Product' placeholder if available
  • Combines line item data with product data
  • Supports custom lookup field mappings (such as 'name:type') where the first field is a field in lineItem and the second is part of the Product
  • Values must match in order with their corresponding lookup fields
Lookup Promo Codes

Lookup Promo Codes

This action looks up and populates promo codes for the current activity.

Parameters

Parameter Type Format Description
Promo Codes String/Array Text Codes to lookup
Load Target Object JSON Optional. Target object to populate with results. If not provided, uses Context.result.data

JavaScript API

There is no JS API for this action.

Outputs

Populates target (or Context.result.data) with:

  • promoCodes: Array of promo code objects with their definitions

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
9999 Promo codes not passed to lookup Required promo codes parameter is missing

Additional Considerations

  • Validates promo codes parameter is provided
  • Queries both PromoCode and PromoCodeDef collections
  • Returns empty array if no matching codes found
  • Supports both single code string and array of codes
  • Populates definition details for each code
Lookup Promo Limits

Lookup Promo Limits

This action looks up and populates promotion rule limits for the current activity.

Parameters

None. Uses the current activity context.

JavaScript API

There is no JS API for this action.

Outputs

Populates Context.promoRuleLimits with:

  • Object mapping rule IDs to their limit objects
  • Each limit contains: rule, redemptions, availableRedemptions, budgetUsed, availableBudget

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Filters limits by:
    • Program from context member
    • Not trashed
    • Effective dates:
      • effectiveTo is null or >= activity date
      • canPreview is true or effectiveFrom <= activity date
  • Returns an empty object if no limits are found
  • Organizes limits by rule ID for easy lookup
  • Supports preview mode through the canPreview flag
Lookup Purse Policies

Lookup Purse Policies

This action looks up and populates purse policies based on lookup criteria.

Parameters

Parameter Type Format Description
Lookup Field String Text Optional. Field to filter policies by
Lookup Values String/Array Text Optional. Values to match against lookup field
Purse Policy Filter Object JSON Optional. Additional filter criteria for policies

JavaScript API

UDF.populatePursePolicies(lookupField, lookupValues, pursePolicyFilter, callback)

Outputs

Populates `Context.pursePolicies1 with array of purse policy objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • If lookup values are provided but not in an array, splits on the comma
  • Trims whitespace from lookup values
  • Combines lookup field filter with any additional filter criteria
  • Always filters by program from the context member
  • Returns an empty array if no policies are found
  • Combines with any existing purse policies in context
  • Uses Map to deduplicate policies by ID
Lookup Reward Policies

Lookup Reward Policies

This action looks up and populates reward policies based on lookup criteria.

Parameters

Parameter Type Format Description
Lookup Field String Text Required. Field to filter policies by
Lookup Values String/Array Text Optional. Values to match against lookup field
Select Fields String/Array Text Optional. Fields to include in returned policies

JavaScript API

UDF.populateRewardPolicies(lookupField, lookupValues, selectFields, callback)

Outputs

Populates Context.activity.rewardPolicies with array of reward policy objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Returns early if the lookup field isn't provided
  • If lookup values are provided but not in an array, splits on the comma
  • Trims whitespace from lookup values
  • Returns an empty array if no policies are found
  • Combines with any existing reward policies in the context
  • Uses Map to deduplicate policies by ID
  • Supports field selection to limit returned data
Lookup Tier History

Lookup Tier History

This action looks up and populates tier history records for the current member.

Parameters

None. Uses the current member context.

JavaScript API

UDF.populateTierHistory(callback)

Outputs

Populates Context.member.tierHistory with array of tier history objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • Filters the tier history by member ID
  • Combines with any existing tier history in the context
  • Returns an empty array if no history is found
  • Uses concat to preserve the order of history records
Lookup Tier Policies

Lookup Tier Policies

This action looks up and populates tier policies based on lookup criteria.

Parameters

Parameter Type Format Description
Lookup Field String Text Optional. Field to filter policies by
Lookup Values String/Array Text Optional. Values to match against lookup field
Select Fields String/Array Text Optional. Fields to include in returned policies

JavaScript API

UDF.populateTierPolicies(lookupField, lookupValues, selectFields, callback)

Outputs

Populates Context.tierPolicies with array of tier policy objects.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • If lookup values are provided but not in an array, splits on the comma
  • Trims whitespace from lookup values
  • Returns an empty array if no policies are found
  • Combines with any existing tier policies in the context
  • Uses Map to deduplicate policies by ID
  • Supports field selection to limit returned data
Lookup User

Lookup User

This action looks up and populates user information for the current context.

Parameters

None. Uses the current user context.

JavaScript API

UDF.populateUser(callback)

Outputs

Populates Context.user with a user object, excluding any sensitive fields (such as password, and so on).

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
1007 User not found No user found in context or database

Additional Considerations

  • Returns early if no user is in the context
  • Excludes sensitive fields from the returned user object
  • Sets Context.user.id to user._id
Lookup Qualified Purses

Lookup Qualified Purses

This action looks up and populates qualified purses based on lookup criteria.

Parameters

Parameter Type Description
Group Names Multi-Select Searchable Dropdown Used to select the group names from the drop-down

JavaScript API

UDF.lookupQualifiedPurses(groupNames, callback)

Outputs

Populates Context.qPurses with object key is group name and corresponding value is the qualified purse name.

qPurses: {
    "Qualifying Nights": "Qualifying Nights 2025",
    "Qualifying Spend": "Qualifying Spend 2025"
}

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations.

Additional Considerations

  • It retrieves qualified purses based on the selected groups.
  • If no group names are selected, it fetches qualified purses from all groups within the program and assigns them to the qPurses in the context.

Segments & Preferences

Add Segment

Add Segment

This action adds a segment to a member. Segments are used to group members based on defined criteria.

Parameters

Parameter Type Format Description
Segment String Dropdown Select the segment to add to the member. If you want the segment name to be variable based on a calculated field, choose the Variable in this drop down and fill in the Segment Name field that appears next to the dropdown.

Outputs

Returns the added segment object.

JavaScript API

UDF.addSegment(segmentId, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1528 Duplicate segment Reported if the segment already exists for member
1623 Invalid segment IDs Reported if the segment ID is invalid

Additional Considerations

  • In the Rule Builder the Segment name is a drop-down, showing all the Segments. You can select Variable if you would like to compute the Segment Name parameter at run-time.
  • Events are generated before database updates
  • Updates member document with new segment
  • Validates segment exists in program before adding
Remove Segment

Remove Segment

This action removes a segment from a member.

Parameters

Parameter Type Format Description
Segment String Dropdown Select the segment to remove from the member. If you want the segment name to be variable based on a calculated field, choose the Variable in this drop down and fill in the Segment Name field that appears next to the dropdown.

Outputs

Returns the removed segment object.

JavaScript API

UDF.removeSegment(segmentId, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1623 Invalid segment IDs Reported if the segment ID is invalid

Additional Considerations

  • In the Rule Builder the Segment name is a drop-down, showing all the Segments. You can select Variable if you would like to compute the Segment Name parameter at run-time.
  • Updates member document to remove the segment
  • Validates segment exists before removing
Add Preference

Add Preference

This action adds a preference to a member. Preferences can be configured with optional expiration dates and categories.

Parameters

Parameter Type Format Description
Preference Name String Text Name of the preference to add
Preference Value String Text Value to set for the preference
Optin Date Date/Time JS Date Optional. When the preference was opted into
Expiration Date Date/Time JS Date Optional. When the preference expires
Category String Text Optional. Category for the preference. Defaults to 'Preference'

Outputs

Returns the created preference object.

JavaScript API

UDF.addPreference(prefName, prefValue, optinDate, expirationDate, category, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1661 Invalid preference name Reported if the preference name is invalid
1662 Invalid member ID for preference Reported if the member ID is invalid

Additional Considerations

  • If no category is provided, defaults to 'Preference'
  • Preferences are stored in a separate collection and linked to the member
  • Updates existing preference if name already exists for member
  • Automatically sets creation and update timestamps
  • Events are generated before database updates
  • Member document is updated to remove processed preferences
Remove Preference

Remove Preference

This action removes a preference from a member by its name.

Parameters

Parameter Type Format Description
Preference Name String Text Name of the preference to remove

Outputs

Returns the removed preference object.

JavaScript API

UDF.removePreference(prefName, prefValue, optinDate, expirationDate, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1661 Invalid preference name Reported if the preference name is invalid
1662 Invalid member ID for preference Reported if the member ID is invalid

Additional Considerations

  • Preference is marked as cancelled in the preferences collection
  • Member document is updated to remove the processed preference
  • Events are generated before database updates
  • Automatically sets update timestamp on the preference record

Streaks & Goals

Begin Streak

Begin Streak

This action starts a new streak instance for a member.

Parameters

Parameter Type Format Description
Opts Object Text Optional. Options for starting the streak. See the structure below.

The Opts object can contain:

{
  streakPolicyId: string,   // Optional. ID of the streak policy. Defaults to current rule's streakPolicyId
  startedAt: Date,         // Optional. When the streak starts. Defaults to activity date
  status: string,          // Optional. Initial status. Defaults to 'Active'
  value: number,          // Optional. Initial value. Defaults to 0
  errorOnExisting: boolean, // Optional. Whether to error if active streak exists. Defaults to false
  errorOnInstanceLimit: boolean, // Optional. Whether to error if instance limit exceeded. Defaults to false
  errorOnCoolOffTime: boolean,  // Optional. Whether to error if cool off time not met. Defaults to false
  goalValues: Array,      // Optional. Override policy goal values if memLevelOverride flag is true
  ctlGroup: any          // Optional. Control group value
}

JavaScript API

UDF.beginStreak(opts, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1790 Unable to begin streak Reported if streak already exists in active status (when errorOnExisting is true)
1794 Instance limit exceeded Reported if streak instance limit is exceeded (when errorOnInstanceLimit is true)
1795 Streak definition not found Reported if the streak policy definition can't be found

Additional Considerations

  • Validates that the streak policy exists and is configured correctly
  • Checks the instance limits against policy settings
  • Validates that the cool off time between streak instances
  • Supports goal value overrides if the policy allows
  • Emits instance limit and cool off skip events when those conditions occur
Cancel Streak

Cancel Streak

This action cancels an active streak instance and all its goals.

Parameters

Parameter Type Format Description
Opts Object Text Optional. Options for canceling the streak. See structure below.

The Opts object can contain:

{
  streakPolicyId: string,   // Optional. ID of the streak policy. Defaults to current rule's streakPolicyId
  date: Date               // Optional. Date of cancellation. Defaults to activity date
}

JavaScript API

UDF.cancelStreak(opts, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1792 No active streak Reported if there is no active streak for the member
1795 Streak definition not found Reported if the streak policy definition can't be found

Additional Considerations

  • Sets the streak status to 'Cancelled'
  • Sets all active goals to 'Cancelled'
  • Sets the cancellation date on the streak and all goals
  • Only cancels streaks that are in 'Active' status
Evaluate Streak

Evaluate Streak

This action evaluates active goals and the overall streak status.

Parameters

Parameter Type Format Description
Opts Object Text Optional. Options for streak evaluation. See structure below.

The Opts object can contain:

{
  streakPolicyId: string,   // Optional. ID of the streak policy. Defaults to current rule's streakPolicyId
  date: Date,              // Optional. Date of evaluation. Defaults to activity date
  postEndEval: boolean     // Optional. Indicates evaluation is running after end date. Defaults to false
}

JavaScript API

UDF.evalStreak(opts, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1792 Streak "%s" does not exist or is not active Reported if there is no active streak for the member
1795 Unable to locate streak definition for policy "%s" Reported if the streak policy definition can't be found

Additional Considerations

  • Evaluates completion and expiration of both goals and the overall streak
  • Goals can expire based on time limits from streak start or goal start
  • Streak completes when the required number of goals are completed
  • Streak expires if too many goals expire to meet the completion requirements
  • All goal statuses are evaluated before the streak status
Advance Streak Goal

Advance Streak Goal

This action advances a member's streak goal value when they perform a qualifying activity.

Parameters

Parameter Type Format Description
Opts Object Text Optional. Options for advancing the streak goal. See structure below.

The Opts object can contain:

{
  streakPolicyId: string,   // Optional. ID of the streak policy. Defaults to current rule's streakPolicyId
  goalName: string,         // Optional. Name of the goal to advance. Defaults to current rule's goalName
  date: Date,              // Optional. Date of the advancement. Defaults to activity date
  value: number,           // Optional. Value to add to goal. Defaults to 0
  consumeRemainder: boolean // Optional. Whether to consume remainder after reaching target. Defaults to false
}

JavaScript API

UDF.advanceGoal(opts, callback)

Events Triggered

Possible Errors

Error Code Error Message Description
1791 Goal not advanced Reported if the goal could not be advanced
1792 No active streak Reported if there is no active streak for the member
1793 Goal not found Reported if the specified goal is not found

Additional Considerations

  • Only advances the goal if member has an active streak
  • Validates goal exists before advancing
  • Only emits event if goal value actually changes
  • If consumeRemainder is false, any value above the goal target is returned as remainder
  • Goal value is rounded to streak policy's precision setting

Badges & Tiers

Give Badge

Give Badge

This action adds a badge to a member.

Parameters

Parameter Type Format Description
Badge Name String Text The name of the badge to add

JavaScript API

UDF.addBadge(badgeName, callback)

Events Triggered

Possible Errors

| Error Code | Error Message | Description | |-|-|-|-| | 1524 | Please use unique badge name for field name | Reported if member already has a badge with the given name |

Additional Considerations

  • Includes activity ID, rule ID, and timestamps in badge metadata
  • Badge is added to member.badges array
Set Tier

Set Tier

The action sets a specific tier level for a member, with optional expiration and lock dates. This is both a rule action and a user-defined function (UDF).

Parameters

Parameter Type Format Description
Tier string Tier name Tier identifier
Level string Level name Level identifier
Requalification Date date ISO8601 date Re-qualification date (optional)
Achievement Date date ISO8601 date Achievement date (optional)
Lock Date date ISO8601 date Lock date (optional)
Reason string Reason text Reason (optional)
Sub Reason string Sub-reason text Sub-reason (optional)

JavaScript API

UDF.setLevel(tierName, level, requalsOn, achievedOn, lockDate, reason, subReason, cb)

Outputs

  • Updated tier object
  • Sets context.Context.saveMember = true

Events Triggered

Generates the L2 SetTierEvent for the member.

Possible Errors

Error Code Error Message Description
2045 Could not find tier in member with _id %s Tier wasn't found in the member
1737 Please provide the correct level name for Tier Policy: %s and ID: %s Level name wasn't not provided
2046 Tier policy with id %s and program %s was not found Tier policy wasn't found
2047 Tier policy with id %s and program %s does not have level with value %s Level wasn't found in policy
1200 Validation Error General validation failure
1300 Unable to process. Database error Database operation failed

Additional Considerations

  • Requires the "TierAdjustment" permission with "update"
  • Validates that the level and tier exist
  • Emits SetTierEvent
  • Updates database
  • Supports metadata (requalsOn, achievedOn, lockDate, reason, subReason)

Flow Control

Custom Action

Custom Action

This action executes custom JavaScript code with access to the member context.

Parameters

Parameter Type Format Description
Custom action Function Text JavaScript function to execute. Must follow format: function(param, context, callback)
Parameter Any Text Parameter value passed to the custom action function

JavaScript API

None

Events Triggered

Possible Errors

Error Code Error Message Description
9999 Custom Action needs to be a function Reported if custom action is not a valid function
9999 Errors occurred while executing rules Reported if the custom action throws an error during execution

Additional Considerations

  • Custom action function must follow the signature: function(param, context, callback)
  • Function must call callback(error) for failures or callback(null) for success
  • Has access to full member context through the context parameter
  • Custom JavaScript validation is performed before execution
  • Function runs in a sandboxed environment with limited global access
Do Not Fire Rule

Do Not Fire Rule

This action prevents a specific rule from firing in the current activity.

Parameters

Parameter Type Format Description
Rule Name String Dropdown Select the rule to prevent from firing

JavaScript API

UDF.doNotFire(ruleName)

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
3302 Rule not found Reported if the specified rule doesn't exist

Additional Considerations

  • Only affects rule execution for the current activity
  • Doesn't modify the rule definition
  • Takes effect immediately when executed
Throw Error

Throw Error

This action explicitly throws an error with a custom message and code.

Parameters

Parameter Type Format Description
Error Message String Text Custom error message to display
Code Number Integer Optional. Error code to use. Defaults to 9999
HTTP Status Code Number Integer Optional. HTTP status code to return
Display Error Context Boolean Text Optional. Whether to include rule context in error. Defaults to true

JavaScript API

UDF.throwError(errorMessage, code, httpStatusCode, displayErrorContext)

Outputs

None. The action throws an error and stops execution.

Events Triggered

No events are generated by this action.

Possible Errors

This action always throws an error with:

  • Code: Provided code or 9999 if not specified
  • Message: Provided error message
  • HTTP Status: Provided status code or 500 if not specified
  • Context: Rule name and failed element if displayErrorContext is true

Additional Considerations

  • Logs error before throwing
  • Error is constructed using the engine.execution error type
  • Error includes the rule context by default
  • Can be used for custom validation or business logic errors
  • Stops rule execution when thrown
  • Error is caught by the rule engine and returned to the client
Override No of Executions

Override No Of Executions

This action overrides the number of times a rule was considered matched and executed for the current activity.

Parameters

Parameter Type Format Description
Execution Count Number Integer Optional. Number of times to count the rule as executed. Defaults to 1

JavaScript API

UDF.overrideNoOfExecutions(executionCount, callback)

Outputs

Updates in Context.activity:

  • matches.executionCount: Set to provided execution count
  • ruleMatch[].executionCount: Updated for current rule's ruleRunId

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action.

Additional Considerations

  • If executionCount isn't provided, defaults to 1
  • Updates both the activity.matches.executionCount and the last ruleMatch entry
  • Only updates the ruleMatch if it matches the current rule's ruleRunId
  • Changes affect how many times subsequent actions in the rule execute
  • Useful for testing and debugging rule execution flows
  • Changes are only for current activity execution

Results & Updates

Get Results

Get Results

This action retrieves sections of the activity result.

Parameters

Parameter Type Format Description
Section String Text The section to retrieve ('data', 'log', 'errors', or any other value for full result)

JavaScript API

UDF.getResults(section)

Events Triggered

No events are generated by this action

Possible Errors

This action doesn't throw any errors.

Additional Considerations

  • Section parameter is case-insensitive
  • Returns specific section for 'data', 'log', or 'errors'
  • Returns entire result object for any other section value
  • Returns undefined if requested section doesn't exist
Set Results

Set Results

This action sets results data in the context for the current activity.

Parameters

Parameter Type Format Description
Section String Text Section to update ('log', 'errors', 'data', or entire result)
Data Any JSON Data to set in the specified section

JavaScript API

UDF.setResults(section, data)

Outputs

Updates Context.result based on section:

  • 'log' or 'errors': Sets array in Context.result[log or errors]
  • 'data': Sets data in Context.result.data
  • other: Sets entire Context.result object

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. JSON.parse() may throw errors if invalid JSON strings are provided.

Additional Considerations

  • Section parameter is case-insensitive
  • For 'log' or 'errors' sections:
    • Single items are wrapped in array
    • String data is parsed as JSON
  • For 'data' section:
    • String data is parsed as JSON
    • Replaces entire data section
  • For other sections:
    • Replaces entire result object
    • String data is parsed as JSON
  • No validation of data structure or content
Extend Results

Extend Results

This action extends the activity result with additional data.

Parameters

Parameter Type Format Description
Section String Text The section to extend ('data', 'log', or 'errors')
Data Object Text The data to merge into the result section

JavaScript API

UDF.extendResults(section, data)

Events Triggered

No events are generated by this action

Possible Errors

This action doesn't throw any errors.

Additional Considerations

  • Section parameter is case-insensitive
  • For 'log' or 'errors' sections, data is converted to an array if it's not already one
  • For all sections, string data is JSON parsed
  • For 'data' section, directly sets Context.result.data
  • For other sections, sets entire Context.result object
Set Persist

Set Persist

This action controls whether the current activity is persisted.

Parameters

Parameter Type Format Description
Flag Boolean Text Whether to persist the activity

JavaScript API

UDF.setPersist(flag, callback)

Outputs

Sets Context.persistAct to the provided flag value.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action.

Additional Considerations

  • Sets whether the current activity is persisted
  • Callback parameter is optional
  • Changes only affect the current activity
  • Useful for testing and debugging scenarios where you don't want activities saved
  • Has no effect on other persistence like member updates
Extend Activity Result Log

Extend Activity Result Log

This action extends the activity result log data with additional fields.

Parameters

Parameter Type Format Description
Data Object Text The data to merge into the activity result log

JavaScript API

UDF.extendActivityResultLog(data)

Events Triggered

No events are generated by this action

Possible Errors

This action doesn't throw any errors.

Additional Considerations

  • Data parameter can be a string (will be JSON parsed) or an object
  • Automatically excludes internal fields ($__, events, __v, trans)
  • If data has a toObject() method, it will be called before merging
  • Merges data into Context.resultLogData
Update Member Offer

Update Member Offer

This action updates properties of an existing offer associated with the member.

Parameters

Parameter Type Format Description
Offer Code String Text Code of the offer to update
Offer Object Object JSON Object containing fields to update

JavaScript API

UDF.updateMemberOffer(offerCode, offerObj, callback)

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur would be database errors propagated from the underlying MongoDB operations. The function handles error cases by:

  • Logging a warning and returning silently if offer code isn't provided
  • Logging a warning and returning silently if no matching offer is found
  • Passing through any database errors from MongoDB operations

Additional Considerations

  • Returns silently if an offer code isn't provided
  • Returns silently if the offer isn't found
  • Sets updatedAt and updatedBy fields automatically
  • Updates offer in both the member.offers array and the offer collection
  • Preserves existing offer fields that weren't specified in the update object
Update Member Reward

Update Member Reward

This action updates properties of an existing reward associated with the member.

Parameters

Parameter Type Format Description
Reward Code String Text Code of the reward to update
Reward Object Object JSON Object containing fields to update

JavaScript API

UDF.updateMemberReward(rewardCode, rewardObj, callback)

Outputs

Returns the updated reward object.

Events Triggered

No events are generated by this action.

Possible Errors

No errors are thrown directly by this action. Any errors that occur are database errors propagated from the underlying MongoDB operations. The function handles error cases by:

  • Logging a warning and returning silently if reward code isn't provided
  • Logging a warning and returning silently if no matching reward is found
  • Passing through any database errors from MongoDB operations

Additional Considerations

  • Returns silently if a reward code isn't provided
  • Returns silently if the reward isn't found
  • Updates the reward in both the member.rewards array and the reward collection
  • Sets updatedAt and updatedBy fields automatically
  • Preserves the existing reward fields that weren't specified in the update object

Referrals

Generate Referral Code

Generate Referral Code

This action generates a unique referral code for a member.

Parameters

This action takes no parameters.

Outputs

Sets the member.referralCode value.

JavaScript API

UDF.generateReferralCode(callback)

Events Triggered

No events are generated by this action

Possible Errors

This action doesn't throw any errors.

Additional Considerations

  • Only generates a new code if the member doesn't already have one
  • Uses nanoid() to generate unique codes
Lookup Referrer

Lookup Referrer By Code

This action looks up and populates referrer member information using a referral code. This is useful when an enrollment happens with a referralCode that was issued by another member. This action loads that member into the context.

Parameters

Parameter Type Format Description
Referral Code String Text Code to lookup referrer by

JavaScript API

UDF.lookupReferrerByCode(referralCode, callback)

Outputs

Populates Context with:

  • referrerMember: The referrer member object (excluding transient fields)
  • referrerLoyaltyId: The referrer's loyalty ID if found

Events Triggered

No events are generated by this action.

Possible Errors

Error Code Error Message Description
2038 Referrer with code %s not found The specified referral code wasn't found

Additional Considerations

  • Returns early if no referral code is provided
  • Looks up the loyalty ID for the referrer if available
  • Returns silently if the loyalty ID isn't found

User Management

Get User Roles

Get User Roles

This action retrieves the roles assigned to the current user.

Parameters

This action takes no parameters.

Output

Sets Context.user.roles with the retrieved roles as an array.

JavaScript API

UDF.getUserRoles(callback)

Events Triggered

No events are generated by this action

Possible Errors

This action propagates any errors from the ACL system but doesn't directly throw any errors.

Additional Considerations

  • Sets Context.user.roles with the retrieved roles
  • Returns both user login and roles array in the result
  • Returns an empty array for roles if none are found
  • Uses the current user's login from cls context